iOS 9未loginFacebooklogin?

我正在使用Xcode 7.0,在iOS 9.0.2上testing并使用Facebook SDK 4.7.0。 代码= 308“(空)”的问题发生在iOS 9.我在我的项目中使用的Objective-C代码。 如何解决这个问题? 下面附上我的代码。

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; [login logInWithReadPermissions:@[@"public_profile",@"email", @"user_friends"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error){ if ([FBSDKAccessToken currentAccessToken]) { startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { if (!error) { } }]; } }]; 

iOS9.2.1

这解决了我的308问题

打开“源代码”,plist文件,searchLSApplicationQueriesSchemes,然后根据需要添加/修改。

 <key>LSApplicationQueriesSchemes</key> <array> <string>fbauth2</string> <string>fbapi</string> <string>fb-messenger-api</string> <string>fbshareextension</string> </array> 

试试这个代码:

  FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; login.loginBehavior = FBSDKLoginBehaviorWeb; [login logInWithReadPermissions:@[@"email"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { if (error) { // Process error } else if (result.isCancelled) { // Handle cancellations } else { if ([result.grantedPermissions containsObject:@"email"]) { NSLog(@"result is:%@",result); [self fetchUserInfo]; [login logOut]; } } }]; 

我认为这是相关的新的iOS 9的url处理scheme

您需要在LSApplicationQueriesSchemes项下将可信的URL添加到您的plist

相关的问题

  - (IBAction)facebookClick:(id)sender { FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; [login logOut]; login = [[FBSDKLoginManager alloc] init]; login.loginBehavior = FBSDKLoginBehaviorWeb; [login logInWithReadPermissions:@[@"email"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { if (error) { NSLog(@"Process error"); // [login logOut]; } else if (result.isCancelled) { NSLog(@"Cancelled"); // [login logOut]; } else { NSLog(@"Logged in"); [self getUserInformation]; } }]; } 

对于使用xCode 8的 iOS 10

在“ function”选项卡中设置项目的“ 钥匙串共享”目标