无法获得Facebook用户名

时间:2018-02-06 14:36:06

标签: ios facebook

使用FBSDK,我按如下方式设置了一个分享按钮:

-(void) setFBShareButton{
    [self.facebookButton addTarget:self action:@selector(postFacebook:) forControlEvents:UIControlEventTouchUpInside];
    FBSDKShareLinkContent * content = [[FBSDKShareLinkContent alloc]init];
    //some logic
    self.FBSharebutton.shareContent = content;
}

点击该按钮时,会调用此方法:

-(void)postFacebook:(UIButton*)sender{
    [self.FBSharebutton sendActionsForControlEvents:UIControlEventTouchUpInside];
    if ([FBSDKAccessToken currentAccessToken]) {
       //nothing...
    }
}

此时,我需要获取Facebook用户名,但正如您在上面的评论中所看到的,我没有访问令牌,我认为我需要这些信息。

为了记录,我在AppDelegate中也有这个:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[FBSDKApplicationDelegate sharedInstance] application:application
                             didFinishLaunchingWithOptions:launchOptions];
}

我错过了哪一部分?

0 个答案:

没有答案