不发送 Facebook 游戏请求/邀请

我正在尝试实现游戏请求/邀请。 Facebook 没有返回任何错误,我可以使用相同的游戏/应用配置在用户时间轴中共享状态。

这是我的代码:

// -----------------------------------------------------------------------
//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];
}

我已经在 Facebook 中检查了我的应用设置。我的 Bundle ID 在我的 plist 中是相同的,我还从 AppStore 输入了我的 iPhone Store ID。

这是我在时间轴上共享状态的代码,效果很好:

// -----------------------------------------------------------------------
//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];

}
stack overflow Not sending facebook game request/invite
原文答案

答案:

作者头像

已经解决了。由于某种原因,我朋友的 Facebook 版本是旧版本,没有收到任何消息。对于更新 Facebook 布局的其他朋友,它正在工作。