ios – FBSDK(新的Facebook SDK 4.0)实现不适用于使用Facebook登录

我正在使用Facebook开发人员提到的以下块.但是当我的应用程序从浏览器回调时,它总是返回已取消的结果.

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"]     
        handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
  if (error) {
        // Process error
   }
  else if (result.isCancelled) {
        // Handle cancellations
   }
   else {
       // If you ask for multiple permissions at once, you
       // should check if specific permissions missing
       if ([result.grantedPermissions containsObject:@"email"]) {
        // Do work
       }
  }
 }];

this update comes on 25 March 15,

如果有人使用这个,请与我分享.

参考:https://developers.facebook.com/docs/ios/getting-started

您必须在appDelegate中添加以下方法

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                          openURL:url
                                                sourceApplication:sourceApplication
                                                       annotation:annotation];
}

如果上述方法不存在于AppDelegate中,则会导致取消状态.

参见:https://developers.facebook.com/docs/ios/getting-started#startcoding

代码日志版权声明:
翻译自:http://stackoverflow.com/questions/29363490/fbsdk-new-facebook-sdk-4-0-implementation-is-not-working-for-login-with-facebo

转载注明原文:ios – FBSDK(新的Facebook SDK 4.0)实现不适用于使用Facebook登录