我正在尝试获取 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