我的应用登录屏幕,
第一次尝试时,Facebook 登录按钮无法打开 Safari 浏览器,而第二次尝试时,它工作正常。
下面是我尝试过的代码:
FBSDKLoginManager *manager = [FBSDKLoginManager new];
manager.loginBehavior = FBSDKLoginBehaviorBrowser;
NSArray *permissions = @[@"email",@"public_profile"];
[manager logInWithReadPermissions:permissions fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error){
if(error) {
[self showAlertWith:@"Oops!" message:@"Login Failed, try again" handler:nil];
return;
}
if(result.isCancelled) {
[self showAlertWith:@"Oops!" message:@"Login Failed, try again" handler:nil];
return;
}else {
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me"
parameters:@{@"fields": @"picture, name, email"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id userinfo, NSError *error) {
if(!error) {
if([FBSDKAccessToken currentAccessToken]) {
[self makeGraphRequest];
}
}else {
EKLog(@"error %@", error);
}
}];
}
}];
第一次单击登录按钮时,会调用 loginWithReadPermission
但不会调用回调 block ,而再次单击时,则会调用回调处理程序。任何帮助将不胜感激,谢谢。
最佳答案
如果可行,您可以尝试一种解决方案!
将FBSDKLoginManager *manager
声明为实例变量或属性,并在viewDidload
中对其进行初始化,
FBSDKLoginManager *manager = [FBSDKLoginManager new];
然后使用!!这可能是因为本地声明而发生的!
关于ios - 首次尝试登录时,iOS 中的 Facebook 登录无法打开 safari,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44236733/