AWSMobileClient initialise returns user-state "SignedIn" after uninstalling and then installing application

593 Views Asked by At

I am using aws-cognito UserPool (via. AWSMobileClient) for authentication of users to access the AWS Services. Currently the user may choose to log-in via Phone, Google and Facebook using Hosted UI option, which requires to initialise the AWSMobileClient, via. AWSMobileClient.default().initialize(<#T##completionHandler: (UserState?, Error?) -> Void##(UserState?, Error?) -> Void#>) Which returns me the current user state.

Use Case : I sign in to my application via UserPool, and the uninstall the application. When reinstalling the application I fetch the current user state, it returns as “Signed-In”.

How may I stop this behaviour?

1

There are 1 best solutions below

1
Mohammad Sadiq On

The "problem" is that AWS SDK stores the login information in the keychain, and this information is not deleted when the app is uninstalled.

Solution is to perform a signout in the first access of the user to the app. Use a Bool in UserDefaults to know if it is the first access.