Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if user have an iOS integrated Facebook account setup before request session?

It seems to me, thath at the very first session opening request, the iOS integrated Facebook, and the old "app switching" authorization works in a different way.

The first needs to open the session with read permissions only, then ask for publish permission at publish time.

The old one needs to request for every permission at the first time, so app will be able to post later on (otherwise not).

So I split the session opening logic in my facebook connect method:

-(void)connectWithSuccess:(EPPZSuccessBlock) successBlock
                     fail:(EPPZFailBlock) failBlock
{
    if (FBSession.activeSession.isOpen)
    {
        if (successBlock) successBlock();
        [self socialServiceDidConnect:self];
    }

    else
    {
        //This is what I need to decide somehow.
        BOOL userHaveIntegrataedFacebookAccountSetup = NO;

        if (userHaveIntegrataedFacebookAccountSetup)
        {
            //Request for a session with read permissions only, otherwise iOS integrated Facebook will throw me an exception.
            [FBSession openActiveSessionWithReadPermissions:[NSArray arrayWithObject:@"user_about_me"]
                                               allowLoginUI:YES
                                          completionHandler:^(FBSession *session, FBSessionState status, NSError *error)
             { [self handleOpenSessionResponseWithSession:session status:status error:error success:successBlock fail:failBlock]; }];
        }
        else
        {
            //Request for session with every (incuding publish) permissions, otherwise non integrated Facebook won't let the app to post later.
            [FBSession openActiveSessionWithPublishPermissions:self.publishPermissions
                                               defaultAudience:FBSessionDefaultAudienceEveryone
                                                  allowLoginUI:YES
                                             completionHandler:^(FBSession *session, FBSessionState status, NSError *error)
             { [self handleOpenSessionResponseWithSession:session status:status error:error success:successBlock fail:failBlock]; }];
        }
    }
}

But I need some kind of easy detection of which one to use, so the question goes: How to detect if user have an iOS integrated Facebook account setup before request session?

like image 623
Geri Borbás Avatar asked Dec 11 '22 19:12

Geri Borbás


1 Answers

As far as I know, the proper way to find this out is to use

[SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]

Note that this is iOS 6 and later only! Part of Social.framework.

like image 109
Anton Avatar answered Jan 26 '23 00:01

Anton