Tôi đã sử dụng facebook SDK để xác thực với facebook. Khi không có tài khoản facebook bật trong cài đặt sau đó bằng cách click vào các ứng dụng nút đi Safari để xác thực tức làACAccountType luôn hiển thị 0 tài khoản
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];
}];
khác nếu tài khoản facebook được kích hoạt sau đó
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];
}
}];
}
}
này hình ảnh hiển thị cảnh báo để truy cập thông tin người dùng. Nó hoạt động tốt trong trình mô phỏng. Nhưng trong thiết bị nó luôn luôn đi đến safari hoặc trong ứng dụng facebook để xác thực ngay cả tài khoản facebook được kích hoạt trong cài đặt. Xin hãy giúp tôi để tìm ra vấn đề này.
Cảm ơn tất cả.
Bạn đã gọi 'requestAccessToAccountsWithType: options: completion:'? – Wain
@Tôi nên gọi nó ở đâu? –