Facebook 로그인, Facebook 공유 또는 Facebook Gaming을 통합하고 나서 특정 앱 이벤트가 이벤트 관리자에 대해 자동으로 로깅 및 수집됩니다. 단, 자동 앱 이벤트 로깅을 비활성화하는 경우는 예외입니다. Facebook 로그인, Facebook 공유 또는 Facebook Gaming을 사용하는 모든 개발자 여러분께서는 이 기능의 작동 방법을 숙지하시기 바랍니다. 수집되는 정보 및 자동 앱 이벤트 로깅을 비활성화하는 방법에 대한 자세한 내용은 자동 앱 이벤트 로깅을 참조하세요.
Gaming Services is available as a new component in the official Facebook SDK for Android. Using Facebook official SDKs is the recommended approach and makes it easy to access services enabled by Facebook Login for Gaming including the Player Finder and Sharing (for Gaming) experiences.
Facebook Login for Gaming enable a new login method for games. It supports the same implementation and SDK methods as Facebook Login. If this is the first time you're integrating the Facebook SDK into your App, refer to the configuration guide before proceeding. Instead of receiving |
After integrating with Facebook Login for Gaming, your application will receive an access token for use on Gaming graph domain (graph.fb.gg), instead of the Facebook graph domain (graph.facebook.com). Read more about gaming graph domain.
You can check if the current User has connected with Facebook Login For Gaming by verifying the Graph Domain to be gaming
in the Access Token:
// (c) Facebook, Inc. and its affiliates. Confidential and proprietary. ... import com.facebook.AccessToken; ... AccessToken currentAccessToken = AccessToken.getCurrentAccessToken(); if (currentAccessToken != null && currentAccessToken.getGraphDomain.equals("gaming")) { // current user has been migrated to Facebook Login for Gaming }
Here's an example of how you would invoke the Player Finder dialog and handle the Dialog Close event using the Android SDK.
// (c) Facebook, Inc. and its affiliates. Confidential and proprietary. ... import com.facebook.FacebookCallback; import com.facebook.FacebookException; import com.facebook.gamingservices.FriendFinderDialog; ... public class MainActivity extends Activity { ... public void openFriendFinderDeepLink(View view) { FriendFinderDialog dialog = new FriendFinderDialog(this); // if we want to get notified when the dialog is closed // we can register a Callback dialog.registerCallback( this.callbackManager, new FacebookCallback<FriendFinderDialog.Result>() { @Override public void onSuccess(FriendFinderDialog.Result friendFinderResult) { Log.e(MainActivity.TAG, "Player Finder Dialog closed"); } @Override public void onCancel() {} @Override public void onError(FacebookException exception) { Log.e("GamingServicesFBCallback", exception.toString()); } }); // open the dialog dialog.show(); } ... }
This is an example of how you would handle asset uploads (images and videos) and invoke the Share Dialog using the Android SDK.
Depending on how you design the Share experience in your application, it can be a synchronous flow where the user waits for Upload → Share Dialog. Alternatively, you can perform the upload in the background during gameplay asynchronously and allow the user to share at a later stage through their media library on Facebook.
The user will receive a Facebook notification once the asset is uploaded and ready.
// (c) Facebook, Inc. and its affiliates. Confidential and proprietary. ... import com.facebook.GraphRequest; import com.facebook.GraphResponse; import com.facebook.gamingservices.GamingImageUploader; import com.facebook.gamingservices.GamingVideoUploader; ... public class MainActivity extends Activity { private CallbackManager callbackManager; private ProgressBar videoUploadProgress; ... private void uploadPhoto(Uri imageUri) { GamingImageUploader imageUploader = new GamingImageUploader(getApplicationContext()); try { imageUploader.uploadToMediaLibrary( "My Test Image", imageUri, true, new MediaUploadCallback(getApplicationContext(), false)); } catch (FileNotFoundException e) { Log.e(MainActivity.TAG, e.toString()); } } private void uploadVideo(Uri videoUri) { GamingVideoUploader videoUploader = new GamingVideoUploader(getApplicationContext()); try { videoUploader.uploadToMediaLibrary( "My Test Video", videoUri, new VideoUploadCallback(getApplicationContext(), videoUploadProgress)); } catch (FileNotFoundException e) { Log.e(MainActivity.TAG, e.toString()); } } } class MediaUploadCallback implements GraphRequest.Callback { private static final String TAG = "MediaUploadCallback"; private boolean is_video; private Context context; public MediaUploadCallback(Context context, boolean is_video) { this.is_video = is_video; this.context = context; } public void onCompleted(GraphResponse response) { if (response.getError() != null) { Log.e(MediaUploadCallback.TAG, "Media Upload Failed: " + response.getError().toString()); } else { String mediaID = response.getJSONObject().optString(is_video ? "video_id" : "id"); CharSequence text = "Upload Complete. Media ID: " + mediaID; Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT); toast.show(); } } } class VideoUploadCallback extends MediaUploadCallback implements GraphRequest.OnProgressCallback { private ProgressBar progressBar; public VideoUploadCallback(Context context, ProgressBar progressBar) { super(context, true); this.progressBar = progressBar; } // Update an Android ProgressBar with the current upload progress public void onProgress(long current, long max) { int progress = (int) Math.round(((double) current / (double) max) * 100.0); this.progressBar.setProgress(progress); } }