我正在使用Xcode 7.0,在iOS 9.0.2上测试并使用Facebook SDK 4.7.0。 代码= 308"(null)" 问题发生在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) {
}
}];
}
}];
答案 0 :(得分:4)
iOS9.2.1
这解决了我的308问题
打开源代码',plist文件,搜索LSApplicationQueriesSchemes,然后根据需要添加/修改。
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbshareextension</string>
</array>
答案 1 :(得分:2)
试试这段代码:
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];
}
}
}];
答案 2 :(得分:0)
答案 3 :(得分:0)
- (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];
}
}];
}
答案 4 :(得分:0)