How to determine if an iOS user supports a built-in Facebook account before a request session?

It seems to me that on the first request to open a session, iOS integrated Facebook, and the old "app switching" authorization works differently.

First you need to open a session with read permissions only, and then request publication permission at the time of publication.

The old one needs to be requested for each permission for the first time, so the application will be able to send later (otherwise not).

So, I shared the session opening logic in my facebook connection 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 simple definition of which one to use, so the question is: how to determine if the user has an integrated Facebook account for the iOS account before the request session?

+4
source share
2 answers

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

[SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]

Please note that these are only iOS 6 and later! Part of Social.framework.

+9
source

As Anton said.

 //Facebook setup on users device. BOOL haveIntegratedFacebookAtAll = ([SLComposeViewController class] != nil); BOOL userHaveIntegratedFacebookAccountSetup = haveIntegratedFacebookAtAll && ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]); 
+4
source

All Articles