在我看来,在第一次会话打开请求时,iOS 集成了 Facebook,而旧的“应用程序切换”授权以不同的方式工作。
第一个需要仅以读取权限打开会话,然后在发布时请求发布权限。
旧的需要在第一时间请求每个权限,因此应用程序稍后可以发布(否则不能)。
所以我在我的 facebook 连接方法中拆分了会话打开逻辑:
-(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]; }];
}
}
}
但是我需要某种简单的检测来使用哪个,所以问题是:如何在请求会话之前检测用户是否有 iOS 集成 Facebook 帐户设置?