I just overhauled my codebase to use the new facebook-ios-sdk 3.0 (from the previous version, 2.x or whatnot).
Everything worked great, until I realized I hadn't accounted for users who had already granted the app permission/logged in with the previous implementation of the SDK. So I tried checking to see if the accessToken was saved in NSUserDefaults, and if so, make a call to open a session:
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"FBAccessTokenKey"] &&
[[NSUserDefaults standardUserDefaults] objectForKey:@"FBExpirationDateKey"]) {
[FBSession openActiveSessionWithPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// deal with state change
}
My assumption was that the user wouldn't have to fast app switch for SSO, since they already had. However, that is indeed what happens.
I'd rather not have every existing user need to re-login when upgrading.
Has anyone successfully upgraded without having to re-login?
Thanks
I have upgraded an app with the facebook SDK 3.0 and it worked just fine. The Facebook SDK handles the token itself, but you can still access the accessToken.
You can reach it any time like so:
NSString *accessToken = [FBSession activeSession].accessToken;
This will return the accessToken or a nil if no token is set. You can even define a token caching ruleset on the session. Enjoy.
The answer is in another post by my colleague. We were able to upgrade users from SDK pre 3.0 to 3.1 without needing users to re-login. It involves the use of the FBSessionManualTokenCachingStrategy:
how to avoid logging users out when migrating from iOS Facebook 2.x -> 3.x
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