iosfacebookfacebook-graph-apiaccount-kit

iOS Facebook Account kit - Persist user token when app is opened 2nd time after successful login


My doubt is after successful login using Facebook account kit for the first time, I am reopening the app for the 2nd time. When I open how can I detect and use the existing user Access Token?

I tried by fetching Accountkit.currentAccessToken in appdelegate as a condition to show login page or welcome page. But currentAccessToken returns me null. I have also enabled "Enable Client Access Token Flow" in app settings. Kindly help to understand if my approach is right.

 self.accountKit = AKFAccountKit (responseType: AKFResponseType.accessToken)
        if(self.accountKit.currentAccessToken != nil)
        {
            //SHOW WELCOME PAGE
        }else{
            //SHOW LOGIN PAGE
        }

Solution

  • I am facing the same issue in Android (not in iOS) but I think the problem is same, since in the document says it so.

    this is my code for configuring the login using Email (kotlin, use let to change the val).

    val configurationBuilder = AccountKitConfiguration.AccountKitConfigurationBuilder(
                LoginType.EMAIL,
                AccountKitActivity.ResponseType.CODE)
    

    notice that the response type is AccountKitActivity.ResponseType.CODE

    In the document says:

    If you began the login session with AccountKitActivity.ResponseType.TOKEN, a logout option is available to remove the stored AccessToken from the device.

    So the problem is on the Response type that I use, need to be changed into AccountKitActivity.ResponseType.TOKEN in order to make the token stored on devices.