Anandram Venkataswamy
Anandram Venkataswamy

Reputation: 13

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
        }

Upvotes: 0

Views: 492

Answers (2)

Hayi Nukman
Hayi Nukman

Reputation: 1201

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.

Upvotes: 0

LocoMike
LocoMike

Reputation: 5656

I have seen some issues with Xcode8 / iOS 10 Simulators and keychain save/retrieval. See https://forums.developer.apple.com/thread/60617

AccountKit stores the accessToken securely in the keychain but there is an intermittent bug on Xcode8 / iOS 10 Simulators that makes read/write from keychain fail.

Can you test if this is also happening on a Device? Apparently the problem goes away if you add the Shared Keychain Entitlement to your App, but this is still a bug on Apple.

Upvotes: 0

Related Questions