Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 9 Facebook Access Token is nil on future app launches

After the recent iOS 9 update, along with updates to the Facebook SDK (4.6.0), I'm finding that my login session is no longer persisting between app launches.

My flow so far has been pretty simple.

  1. Login to Facebook using the FBSDKLoginButton.
  2. On future View's and Launches check the FBSDKAccessToken.currentAccessToken() to be able to then use Facebook in the app.

What I'm finding is after the recent updates my AccessToken is now showing up as nil if I close and start the app again. This is a major issue because previously, I only had to login once, and then my session was being automatically renewed.

If I'm correct, login should only occur once, and after that the app should be able to either store the info it needs to connect to Facebook in the future, or simply remain with a token that refreshes itself.

Does anyone have any ideas what might have changed to cause this after the iOS9 or 4.6.0 Facebook SDK updates? Is there properties that need to be persisted to then refresh the token in the future or is the token supposed to renew automatically? I'm near 100% positive, the intended experience with Facebook SDK is NOT to have to login on every app launch (When you restart the app, close all the way and open again).

Thanks!

Update

As requested in a response, I added an additional key into the TransportSecurity info of my Plist file. Unfortunately, no luck still.

enter image description here

like image 639
Unome Avatar asked Oct 01 '15 20:10

Unome


1 Answers

Adding this line on didFinishLaunchingWithOptions worked for me:

FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

Final method looks something like this:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

    if let accessToken = FBSDKAccessToken.currentAccessToken(){
        print(accessToken)
    }else{
        print("Not logged In.")
    }

    return true
}

Reference

like image 69
Mohammad Zaid Pathan Avatar answered Oct 02 '22 17:10

Mohammad Zaid Pathan