iOS 9 Facebook Access Token is nil on future app launches

后端 未结 4 1373
滥情空心
滥情空心 2021-02-05 18:37

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

相关标签:
4条回答
  • 2021-02-05 18:58

    Even it didn't worked for me when I updated my iOS 9 but after try this solution it worked for me.

    1) Add data in info.plist as shown image

    0 讨论(0)
  • 2021-02-05 19:01

    This happened to me also when upgrading to FBSDK 4.18.0

    Downgrading to 4.17.0 solved it for me.

    0 讨论(0)
  • 2021-02-05 19:06

    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

    0 讨论(0)
  • 2021-02-05 19:09

    For iOS 11 / Swift 4 you should add the following code to your AppDelegate:didFinishLaunchingWithOptions

    SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
    

    Final code is:

    import FacebookCore
    
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
            // Override point for customization after application launch.\
    
            // FACEBOOK CONFIGURATION
            SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
    
    
            return true
        }
    
    0 讨论(0)
提交回复
热议问题