我正在尝试获取用户Facebook帐户的全名,应用程序已经在Facebook的iPhone设置中设置了权限,前几天这段代码可以工作,但know不能,我不明白为什么,代码是这样的:
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
发布于 2014-04-01 15:44:35
我相信userFullName只有在iOS 7之后才能使用。也许你是在iOS 7上测试的,现在你在使用iOS 6时遇到了这个问题。有关iOS 6的后备问题,请参阅iOS: user's full name for an ACAccountTypeIdentifierFacebook。
https://stackoverflow.com/questions/20288623
复制相似问题