Depois que você integrar o Login do Facebook, o Compartilhamento do Facebook ou os Jogos do Facebook, alguns eventos do app serão automaticamente registrados e coletados para o Gerenciador de Eventos, a menos que você desabilite o registro automático. Recomendamos que todos os desenvolvedores de apps que usam o Login do Facebook, o Compartilhamento do Facebook ou os Jogos do Facebook entendam como esse recurso funciona. Para saber mais sobre as informações que são coletadas e sobre como desabilitar o registro automático de eventos, consulte Registro automático de eventos do app.
Gaming Services is available as a new component in the official Facebook SDK for iOS. 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 enables 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 <FBSDKCoreKit/FBSDKCoreKit.h> ... if ([[FBSDKAccessToken currentAccessToken].graphDomain isEqualToString:@"gaming"]) { // current user has been migrated to Facebook Login for Gaming }
Here's an example from our sample App, which shows how to invoke the Player Finder and Sharing dialogs through the iOS SDK. It also shows the response you can expect from each of them.
// (c) Facebook, Inc. and its affiliates. Confidential and proprietary. #import "GamingServicesCellController.h" #import <MobileCoreServices/MobileCoreServices.h> #import <UIKit/UIKit.h> #import <FBSDKCoreKit/FBSDKCoreKit.h> #import <FBSDKGamingServicesKit/FBSDKGamingServicesKit.h> #import <FBSDKShareKit/FBSDKShareKit.h> #import "Console.h" static NSString *const kCellIdentifer = @"gaming-services-cell"; @interface MediaPickerDelegate : NSObject <UIImagePickerControllerDelegate, UINavigationControllerDelegate> @property (nonatomic, copy) void (^callback)(id media); @end @implementation MediaPickerDelegate - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { __weak typeof(self) weakSelf = self; [picker dismissViewControllerAnimated:true completion:^{ weakSelf.callback(info[UIImagePickerControllerOriginalImage] ?: [info objectForKey:UIImagePickerControllerMediaURL]); }]; } @end static void UploadImage(UIImage *image) { if (![image isKindOfClass:[UIImage class]]) { ConsoleError([NSError new], @"Bad Image passed to Image Upload"); return; } FBSDKGamingImageUploaderConfiguration *config = [[FBSDKGamingImageUploaderConfiguration alloc] initWithImage:image caption:@"Cool Photo" shouldLaunchMediaDialog:YES]; [FBSDKGamingImageUploader uploadImageWithConfiguration:config andCompletionHandler:^(BOOL success, NSError * _Nullable error) { if (!success || error) { ConsoleError(error, @"Failed to upload Image"); } else { ConsoleSucceed(@"Image Upload Complete"); } }]; } static void UploadVideo(NSURL *videoURL) { if (![videoURL isKindOfClass:[NSURL class]]) { ConsoleError([NSError new], @"Bad URL passed to Video Upload"); return; } FBSDKGamingVideoUploaderConfiguration *config = [[FBSDKGamingVideoUploaderConfiguration alloc] initWithVideoURL:videoURL caption:@"Cool Video"]; [FBSDKGamingVideoUploader uploadVideoWithConfiguration:config andCompletionHandler:^(BOOL success, NSError * _Nullable error) { if (!success || error) { ConsoleError(error, @"Failed to upload Video"); } else { ConsoleSucceed(@"Video Upload Complete"); } }]; } static void LaunchMediaPicker(NSString *type) { static MediaPickerDelegate *mediaDelegate; if (mediaDelegate == nil) { mediaDelegate = [MediaPickerDelegate new]; } UIImagePickerController *const picker = [UIImagePickerController new]; picker.delegate = mediaDelegate; picker.modalPresentationStyle = UIModalPresentationCurrentContext; if ([type isEqualToString:@"VIDEO"]) { picker.mediaTypes = @[(NSString*)kUTTypeMovie, (NSString*)kUTTypeAVIMovie, (NSString*)kUTTypeVideo, (NSString*)kUTTypeMPEG4]; picker.videoQuality = UIImagePickerControllerQualityTypeHigh; mediaDelegate.callback = ^(id media) { UploadVideo(media); }; } else { picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; mediaDelegate.callback = ^(id media) { UploadImage(media); }; } [[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:picker animated:true completion:nil]; } void GamingServicesRegisterCells(UITableView *tableView) { [tableView registerClass:UITableViewCell.class forCellReuseIdentifier:kCellIdentifer]; } UITableViewCell *GamingServicesConfiguredCell(NSIndexPath *indexPath, UITableView *tableView) { UITableViewCell *const cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifer forIndexPath:indexPath]; switch ((GamingServicesCellRow) indexPath.row) { case GamingServicesCellRowFriendFinder: cell.textLabel.text = @"Launch Player Finder"; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; break; case GamingServicesCellRowUploadPhoto: cell.textLabel.text = @"Upload Photo"; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; break; case GamingServicesCellRowUploadVideo: cell.textLabel.text = @"Upload Video"; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; break; } return cell; } void GamingServicesDidSelectCell(GamingServicesCellRow row) { switch (row) { case GamingServicesCellRowFriendFinder: [FBSDKFriendFinderDialog launchFriendFinderDialogWithCompletionHandler:^(BOOL success, NSError * _Nullable error) { if (!success || error) { ConsoleError(error, @"Failed to launch Player Finder"); } else { ConsoleSucceed(@"Friend Finding Complete"); } }]; break; case GamingServicesCellRowUploadPhoto: LaunchMediaPicker(@"IMAGE"); break; case GamingServicesCellRowUploadVideo: LaunchMediaPicker(@"VIDEO"); break; } }