This occurs because the Cognito framework stores login info in the keychain, which persists even after an app is deleted. One way to fix this is to check if the app is a fresh install on application start and logout of the current user if signed in.
To check for fresh installs & updates in my apps, I usually store the build number in UserDefaults and check to see if it is nil or has changed on application start:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let previousBuild = UserDefaults.standard.string(forKey: "build")
let currentBuild = Bundle.main.infoDictionary!["CFBundleVersion"] as! String
if previousBuild == nil {
//fresh install
//logout of current user
} else if previousBuild != currentBuild {
//application updated
}
UserDefaults.standard.set(currentBuild, forKey: "build")
return true
}