我正在尝试获取Facebook帐户的用户全名,该应用程序已在Facebook iPhone设置中获得许可,一天前此代码有效,但不知道,我不明白为什么,这是码:
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
__block ACAccount *facebookAccount;
ACAccountType *facebookTypeAccount = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSDictionary *options = @{ACFacebookAppIdKey:@"mycode",ACFacebookPermissionsKey: @[@"email"]};
[accountStore requestAccessToAccountsWithType:facebookTypeAccount
options:options
completion:^(BOOL granted, NSError *error) {
if(granted){
NSArray *accounts = [accountStore accountsWithAccountType:facebookTypeAccount];
facebookAccount = [accounts lastObject];
NSLog(@"name: %@",[facebookAccount userFullName]);
dispatch_async(dispatch_get_main_queue(), ^{
[self.fb_name setText:[facebookAccount userFullName]];
});
}
}];
这:
NSLog(@"name: %@",[facebookAccount userFullName]);
是null
最佳答案
我相信userFullName仅在iOS 7以后可用。也许您在iOS 7上进行了测试,现在将iOS 6作为目标时遇到了问题。有关iOS 6后备广告的信息,请参见iOS: user's full name for an ACAccountTypeIdentifierFacebook。
关于ios - 获取ACAccount Facebook用户全名为null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20288623/