I've developed an app with Facebook integration and I'm testing multiple failed login scenarios. Then I've saw one that is stucking me.
The scenario is:
The result:
App is getting stuck because it is getting the unauthorized information and I cannot change this anymore because the Facebook account isn't integrated to iOS anymore.
My problem is:
I need to know if the user has set his Facebook credentials on iOS (Settings > Facebook). How can I know it? I've searched Facebook documentation and could not find out.
Here is my code:
+ (void)initFacebook:(void (^)(int))initResult
{
NSLog(@"init: activeSession.state = %i", FBSession.activeSession.state);
[FBSession renewSystemCredentials:^(ACAccountCredentialRenewResult result, NSError *error) {
if (result == ACAccountCredentialRenewResultFailed) {
//User has changed his password and must update his iOS login credentials
NSLog(@"sync: ACAccountCredentialRenewResultFailed -- error.code = %i", error.code);
//Display some message to user…
//Get rid of the token with wrong credentials
[FBSession.activeSession closeAndClearTokenInformation];
FBSession.activeSession = [[FBSession alloc] init];
initResult(1);
}
else if (result == ACAccountCredentialRenewResultRejected) {
//User has unauthorized my App in Settings > Facebook
NSLog(@"sync: ACAccountCredentialRenewResultRejected -- error.code = %i", error.code);
//Display some message to user…
//Get rid of the token with wrong credentials
[FBSession.activeSession closeAndClearTokenInformation];
FBSession.activeSession = [[FBSession alloc] init];
initResult(2);
}
else if (result == ACAccountCredentialRenewResultRenewed) {
//Everything is fine with iOS credentials
NSLog(@"sync: ACAccountCredentialRenewResultRenewed -- error.code = %i", error.code);
//Just to be sure that the session state is right
if (FBSession.activeSession.state == FBSessionStateCreated ||
FBSession.activeSession.state == FBSessionStateCreatedOpening ||
FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
//Open the active session
[FBSession openActiveSessionWithReadPermissions:@[@"basic_info", @"user_photos"]
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
NSLog(@"opensession: activeSession.state = %i", FBSession.activeSession.state);
}];
}
}
}];
}
Thanks!
Your problem is that you're looking for your info in wrong place. Quit looking Facebook SDK docs and go to Social.framework documentation for that. These are about system facebook accounts.