嗨,我正在“使用 facebook 登录”工作,我的代码在下面这里没有进入 if(granted) 循环。在我单击弹出窗口中的“确定”后,控制台打印如下 2012-11-28 15:47:08.558 Tattoo Later[2748:1d34b] type:com.apple.facebook
identifier: B962F897-6BAE-4769-8C04-B1B3D2C872A2
accountDescription: Facebook
username: example@yahoo.co.in
objectID: x-coredata://EBF41CAD-7388-45E0-8621-3958C7A67491/Account/p1
enabledDataclasses: {(
"com.apple.Dataclass.Contacts",
"com.apple.Dataclass.Calendars"
)}
enableAndSyncableDataclasses: {(
)}
properties: {
fullname = "Example";
uid = 100001462475956;
}
parentAccount: (null)
owningBundleID:(null)
点击“使用 Facebook 登录”时的我的代码:
-(IBAction)loginWithFacebookClicked:(id)sender
{
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSArray * permissions = [NSArray arrayWithObjects:@"email",@"user_location", nil];
NSDictionary * dict=[NSDictionary dictionaryWithObjectsAndKeys:@"238864112907671",ACFacebookAppIdKey,permissions,ACFacebookPermissionsKey,ACFacebookAudienceEveryone,ACFacebookAudienceKey, nil];
[accountStore requestAccessToAccountsWithType:accountType options:dict completion:^(BOOL granted, NSError *error) {
if(granted ) {
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
if ([accountsArray count] > 0) {
ACAccount *fbAccount = [accountsArray objectAtIndex:0];
NSLog(@"%@",fbAccount);
}
}
else
{
NSLog(@"%@",[error localizedDescription]);
}
}];
}
最初我遇到了一些错误,例如
Facebook 服务器无法满足此访问请求:代理应用程序无法请求发布权限,除非之前已安装。
Error Domain=com.apple.accounts Code=7 “Facebook 服务器无法完成此访问请求:无效的应用程序 ID” UserInfo=0xa29f520 {NSLocalizedDescription=Facebook 服务器无法完成此访问请求:无效的应用程序 ID}
后来我通过搜索解决了,但我没有得到解决方案
请指导我提前谢谢