Request additional permission Facebook SDK 4 iOS

2020-03-26 08:30发布

I have an app that log in through facebook. When it log in, I only asked for "public_profile", "user_friends" and "email" permission. I know that I can ask for more permission later on, as FB stated:

"Your app can ask for additional permissions at any time, even after a person logs in for the first time. For example, the publish_actions permission lets you post to a person's Facebook Timeline. It's recommended you ask for this permission only when a person is ready to publish a story to Facebook."

So when I was about to post to user's wall, I want to ask for "publish_actions". Please tell me how to do it with Facebook SDK 4. Most of the answer relating to FBSession, activeSession, requestNewPublishPermissions, etc., but in latest Facebook SDK (4.1.0), there is no FBSession class.

2条回答
相关推荐>>
2楼-- · 2020-03-26 08:48

You have to call login method again to request another permission.

FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
[loginManager logInWithPublishPermissions:@[@"publish_actions"]
                                  handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
 {
     if ([result.declinedPermissions containsObject:@"publish_actions"])
     {
         // permission denied
     }
     else
     {
         // do something
     }
 }];
查看更多
再贱就再见
3楼-- · 2020-03-26 08:52

For Parse Developer, it can be an answer.

PFFacebookUtils.linkUserInBackground(user, withPublishPermissions: ["publish_actions"], {
  (succeeded: Bool?, error: NSError?) -> Void in
  if succeeded {
    println("User now has read and publish permissions!")
  }
})

But I am still looking for a more general solution

查看更多
登录 后发表回答