Firebase - Deleting and reinstalling app does not un-authenticate a user

The Firebase authentication session is persisted on the user's device in the iOS keychain. The keychain data for the application is not removed when the application is uninstalled.

If you're looking to manually clear the data, you can store some additional metadata along with your application and manually call FirebaseRef.unauth() to clear the persisted session. See #4747404: Delete keychain items when an app is uninstalled for an additional reference.


Adding below code at the end of didFinishLaunchingWithOptions function (before return true) of AppDelegate works swiftly.

let userDefaults = NSUserDefaults.standardUserDefaults()
if userDefaults.valueForKey("appFirstTimeOpend") == nil {
    //if app is first time opened then it will be nil
    userDefaults.setValue(true, forKey: "appFirstTimeOpend")
    // signOut from FIRAuth
    do {
        try FIRAuth.auth()?.signOut()
    }catch {

    }
    // go to beginning of app
} else {
   //go to where you want
}

For swift 4 the same Answer:

let userDefaults = UserDefaults.standard
if userDefaults.value(forKey: "appFirstTimeOpend") == nil {
    //if app is first time opened then it will be nil
    userDefaults.setValue(true, forKey: "appFirstTimeOpend")
    // signOut from FIRAuth
    do {
        try Auth.auth().signOut()
    }catch {

    }
    // go to beginning of app
} else {
    //go to where you want
}