不发送Facebook游戏请求/邀请

时间:2014-03-22 14:58:30

标签: ios iphone objective-c facebook-sdk-3.1

我正在尝试实施游戏请求/邀请。 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上查看了我的应用设置。 My Bundle ID在我的plist中是相同的,我也从AppStore输入了我的iPhone商店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];


}

1 个答案:

答案 0 :(得分:0)

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