从 iOS Facebook SDK 发出后未收到任何“请求”

Posted

技术标签:

【中文标题】从 iOS Facebook SDK 发出后未收到任何“请求”【英文标题】:Does not receive any "Request" after sending out from iOS Facebook SDK 【发布时间】:2013-07-23 02:51:56 【问题描述】:

我在 Facebook 开发者网站上关注这两个教程 https://developers.facebook.com/docs/tutorials/ios-sdk-games/requests/

https://developers.facebook.com/docs/howtos/send-requests-using-ios-sdk/#step2

这些是我的代码:

[FBWebDialogs presentRequestsDialogModallyWithSession:nil
     message:[NSString stringWithFormat:@"I just smashed %u friends! Can you beat it?", score]
     title: nil
     parameters:params
     handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
    
         if (error)
         
             // Case A: Error launching the dialog or sending request.
             UIAlertView* alert = [[UIAlertView alloc] initWithTitle: @"Facebook" message: error.description delegate: nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];
             [alert show];
             [alert release];
         
         else
         
             if (result == (FBWebDialogResultDialogCompleted))
             
                 // Handle the publish feed callback
                 NSDictionary *urlParams = [self parseURLParams:[resultURL query]];

                 if ([urlParams valueForKey: @"request"])
                 
                     // User clicked the Share button
                     NSLog(@"Send");
                 
             
         
    ];

问题是在我发出请求后,我的朋友告诉我他没有在 FB 通知中心网站收到任何通知/请求。有谁知道为什么?

这些是我做过的事情:

    我已在 info.plist 和 Facebook 应用中正确设置。

    我没有使用沙盒模式。

    我当前的应用程序能够登录并发布到墙上。

    我有publish_actions 的权限。

    我没有收到任何错误或警告。

【问题讨论】:

【参考方案1】:

我在这里找到了我的解决方案: Facebook App Requests aren't shown on iOS devices?

是因为我没有设置iPhone App ID和iPad App ID

【讨论】:

【参考方案2】:

使用以下方法,它会帮助你:

-(void)openFacebookAuthentication

    NSArray *permission = [NSArray arrayWithObjects:kFBEmailPermission,kFBUserPhotosPermission, nil];

    FBSession *session = [[FBSession alloc] initWithPermissions:permission];

    [FBSession setActiveSession: [[FBSession alloc] initWithPermissions:permission] ];

    [[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session, FBSessionState status, NSError *error) 

        switch (status) 
            case FBSessionStateOpen:
                [self getMyData];
                break;
            case FBSessionStateClosedLoginFailed: 
                // prefer to keep decls near to their use
                // unpack the error code and reason in order to compute cancel bool
                NSString *errorCode = [[error userInfo] objectForKey:FBErrorLoginFailedOriginalErrorCode];
                NSString *errorReason = [[error userInfo] objectForKey:FBErrorLoginFailedReason];
                BOOL userDidCancel = !errorCode && (!errorReason || [errorReason isEqualToString:FBErrorLoginFailedReasonInlineCancelledValue]);

                //Added by Rigel Networks July 2, 2013 to solve Facebook Cancel button popup issue
                if(error.code == 2 && ![errorReason isEqualToString:@"com.facebook.sdk:UserLoginCancelled"]) 
                    UIAlertView *errorMessage = [[UIAlertView alloc] initWithTitle:kFBAlertTitle
                                                                           message:kFBAuthenticationErrorMessage
                                                                           delegate:nil
                                                                           cancelButtonTitle:kOk
                                                                           otherButtonTitles:nil];
                    [errorMessage performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];
                    errorMessage = nil;
                    
                
                break;
                // presently extension, log-out and invalidation are being implemented in the Facebook class
            default:
                break; // so we do nothing in response to those state transitions
        
    ];
    permission = nil;

【讨论】:

以上是关于从 iOS Facebook SDK 发出后未收到任何“请求”的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 facebook ios sdk 发出好友请求?

我如何从facebook IOS SDK邀请的朋友那里获得ID?

IOS Facebook SDK,获取用户信息

我在 iOS 上使用 Facebook SDK 收到错误“redirect_uri URL 必须是绝对的”

Facebook iOS SDK - 自定义委托

Facebook iOS SDK:为啥我收到“您必须将此应用升级到 Graph API v2.x”?