ios - 获取ACAccount Facebook用户全名为null

标签 ios objective-c acaccount acaccountstore

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

相关文章:

ios - 从 UIPanGestureRecogniser 获取 UIButton 标题

ios - 使用 XCUI 测试用例测试 UICollectionView 无限滚动

iphone - MPMoviePlayerController - 如何阻止它隐藏其他项目?

ios - 计算器的方案是什么?

iphone - 在 iOS 6 中使用 SLRequest 与 Facebook

iphone - ACAccount 标识符对于所有设备都是唯一的吗?

ios - 音频硬件.cpp :1200:AudioObjectRemovePropertyListener: AudioObjectRemovePropertyListener: no object with given ID 0

ios - UIImageNamed -> 按大小类获取 Assets

iphone - Objective C - 使用 NSURLConnection 发布数据

ios - 使用 "ACAccountStore"登录未获得授权时,我该怎么办?