vendredi 24 juin 2016

Not sending facebook game request/invite


I'm trying to implement Game Request/Invite. Facebook is not returning any errors and I can share status in the user timeline using the same game/app configuration. This is my code: // ----------------------------------------------------------------------- //Facebook login // ----------------------------------------------------------------------- - (void)fbLoginClicked:(id)sender { NSLog(@"-------------------------fbButtonClicked--------------------"); [[NSNotificationCenter defaultCenter] postNotificationName:@"LoginFaceBook" object:nil]; if (!FBSession.activeSession.isOpen) { // if the session is closed, then we open it here, and establish a handler for state changes [FBSession openActiveSessionWithReadPermissions:nil allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState state, NSError *error) { if (error) { NSLog(@"error"); NSLog(@"message error %@", error.localizedDescription); } else if (session.isOpen) { NSLog(@"session is open"); [self pickFriendsButtonClick:sender]; //[self inviteFriends]; //[self publishResult]; //[self publishButtonAction]; NSLog(@"pick Friends button on click"); } }]; } } // ----------------------------------------------------------------------- //Facebook pick friends // ----------------------------------------------------------------------- - (void)pickFriendsButtonClick:(id)sender { NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: nil]; [FBWebDialogs presentRequestsDialogModallyWithSession:nil message:[NSString stringWithFormat:@"I just smashed %d friends! Can you beat it?", score] title:@"Smashing!" parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) { if (error) { // Case A: Error launching the dialog or sending request. NSLog(@"Error sending request."); } else { if (result == FBWebDialogResultDialogNotCompleted) { // Case B: User clicked the "x" icon NSLog(@"User canceled request."); } else { NSLog(@"Request Sent."); } }} friendCache:nil]; } I already checked my app settings in Facebook. My Bundle ID is the same in my plist and I also have input my iPhone Store ID from AppStore. And this is my code for share status on timeline, which is working great: // ----------------------------------------------------------------------- //Share in Facebook // ----------------------------------------------------------------------- - (void)publishResult { // We want to upload a photo representing the gesture the player threw, and use it as the // image for our game OG object. But we optimize this and only upload one instance per session. // So if we already have the image URL, we use it, otherwise we'll initiate an upload and // publish the result once it finishes. NSLog(@"sharing operations starting"); FBRequestConnection *connection = [[FBRequestConnection alloc] init]; NSMutableDictionary<FBOpenGraphObject> *game = [FBGraphObject openGraphObjectForPost]; game[@"type"] = @"fb_sample_rps:game"; game[@"title"] = @"an awesome game of Rock, Paper, Scissors"; game[@"data"][@"player_gesture"] = @"scissor"; game[@"data"][@"opponent_gesture"] = @"paper"; game[@"data"][@"result"] = @"win"; game[@"image"] = @"http://sandbox.yoyogames.com/extras/image/name/san2/853/404853/original/Game1.jpg"; NSLog(@"game object created"); FBRequest *objectRequest = [FBRequest requestForPostOpenGraphObject:game]; [connection addRequest:objectRequest completionHandler:^(FBRequestConnection *innerConnection, id result, NSError *error) { if (error) { NSLog(@"tried to share, but Error: %@", error.description); } else { NSLog(@"message posted"); } } batchEntryName:@"objectCreate"]; NSString *message = @"teste 2"; [connection addRequest:[FBRequest requestForPostStatusUpdate:message] completionHandler:^(FBRequestConnection *innerConnection, id result, NSError *error) { NSLog(@"Error on post update feed"); }]; [connection start]; }

Aucun commentaire:

Enregistrer un commentaire