2

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

4

1 回答 1

0

我相信 userFullName 仅在 iOS 7 之后才可用。也许您在 iOS 7 上进行了测试,现在您在针对 iOS 6 时遇到了问题。请参阅iOS: user's full name for an ACAccountTypeIdentifierFacebook for the iOS 6 fallback。

于 2014-04-01T07:44:35.083 回答