openActiveSessionWithPublishPermissions show login form twice

2.1k views Asked by At

I'm trying to implement post wall using objective-c but when i do request new permission to 'publish_actions' with action session, the FB SDK login form is show again.

I'm looking for this tutorial: https://developers.facebook.com/docs/ios/publish-to-feed-ios-sdk/

In my application flow is basically this:

void (^completionHandler)(FBSession*, NSError*) = ^(FBSession*session, NSError*error){

    if (session.isOpen && !error)
    {
        [FBWebDialogs presentFeedDialogModallyWithSession:session
                                               parameters:params
                                                  handler:handler];
    }
};

// abrie o dialog
BOOL isFBIntegration = [SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook];

if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound)
{
    if(isFBIntegration)
    {
        [[FBSession activeSession] requestNewPublishPermissions:@[@"publish_actions"]
                                                defaultAudience:FBSessionDefaultAudienceFriends
                                              completionHandler:completionHandler];
    }
    else
    {
        [FBSession openActiveSessionWithPublishPermissions:@[@"publish_actions"]
                                           defaultAudience:FBSessionDefaultAudienceEveryone
                                              allowLoginUI:YES
                                         completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
                                             completionHandler(session, error);
                                         }];
    }
}
else
{
    completionHandler(FBSession.activeSession, nil);
}

The user is already logged in because I do ask him to log when it enters the application:

HOME

    [FBSession openActiveSessionWithReadPermissions:@[@"basic_info, user_friends, friends_interests"]
                                       allowLoginUI:YES
                                  completionHandler:nil];

When Facebook is native integration, all right, but when no, openActiveSessionWithPublishPermissions show login form again.

thank you.

1

There are 1 answers

1
Zorayr On

Facebook iOS SDK 3.1 has now disabled openActiveSessionWithPublishPermissions. You will need to first establish a read only session, then additionally request write permissions. You can read more details about the upgrade process at iOS SDK Upgrade Guide.