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?
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.