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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With