Search code examples
iosfacebookfacebook-graph-apifacebook-ios-sdk

How to "rerequest" email permission using Facebook iOS SDK 3.21.1?


Right now my login using Facebook button's tap action maps to the following method:

- (void)openFacebookSession
{
    [FBSession openActiveSessionWithReadPermissions:@[@"public_profile", @"user_friends", @"email"] allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
        [self sessionStateChanged:session state:state error:error];
    }];
}

This works great unless the user denies access to "email". I see in the FB docs that I can re-request access to the user's email one time. According to the FB docs:

If someone has declined a permission for your app, the login dialog won't let your app re-request the permission unless you pass auth_type=rerequest along with your request.

How do I pass "auth_type=rerequest" to Facebook's servers via the iOS SDK? Is there a special method for that?


Solution

  • You can just call the [FBSession requestNewReadPermissions:completionHandler:] method. It will automatically add the rerequest auth_type for you.