我已经使用 facebook SDK 与 facebook 进行身份验证。当设置中没有启用 facebook 帐户时,单击按钮应用程序进入 safari 进行身份验证,即
if (appDelegate.session.state != FBSessionStateCreated)
{
appDelegate.session = [[FBSession alloc] init];
}
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// and here we make sure to update our UX according to the new session state
[self updateView];
}];
否则,如果启用了 facebook 帐户,则
NSArray *fbAccounts=nil;
ACAccountType *accountTypeFB;
if ((_accountStore = [[ACAccountStore alloc] init]) &&
(accountTypeFB = [_accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook] ) ){
fbAccounts = [_accountStore accountsWithAccountType:accountTypeFB];
NSLog(@" %d fbAccounts",[fbAccounts count]);
}
if ([fbAccounts count]!=0) {
[FBSession openActiveSessionWithAllowLoginUI:YES];
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"email",
nil];
[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if (error) {
NSLog(@"Failure");
NSLog(@"error %@",error);
}
else
{
NSLog(@" active session opened ");
if (self.gotUserDetails)
{
return;
}
[self fetchuserinfo];
}
}];
}
}
此图像显示访问用户信息的警报。它在模拟器中运行良好。但在设备中,它总是去 safari 或在 facebook 应用程序中进行身份验证,即使在设置中启用了 facebook 帐户。请帮助我找到这个问题。
谢谢大家。