1

I am working with iOS/Swift and when I delete the app in simulator and rebuild and reinstall the app the user remains logged in. When I run

print(FIRAuth.auth()?.currentUser!.uid)

It returns the user's ID even though I reinstalled the app. Why is it doing this? I'm trying to make it so it performs a segue if a user is signed on already but for some reason even if I rebuild and reinstall the app the user is still logged in.

I am running this code in viewDidAppear as shown in the Google project sample, and it keeps signing in even though I reinstall the app.

if let user = FIRAuth.auth()?.currentUser {
        self.signedIn(user)
    }

func signedIn(user: FIRUser?) {
    MeasurementHelper.sendLoginEvent()

    AppState.sharedInstance.displayName = user?.displayName ?? user?.email
    AppState.sharedInstance.photoUrl = user?.photoURL
    AppState.sharedInstance.signedIn = true
    NSNotificationCenter.defaultCenter().postNotificationName(Constants.NotificationKeys.SignedIn, object: nil, userInfo: nil)
    performSegueWithIdentifier(Constants.Segues.SignInToFp, sender: nil)
}

Is this not the proper way to check if a user is already logged in?

Edit: Well for now I am saving the User UID to NSUserDefaults (NSUserDefaults clears when reinstalling app) and in viewDidAppear checking if it is nil and matches FIRAuth.auth()?.currentUser, but I would like to know what is going on.

gooberboobbutt
  • 797
  • 2
  • 8
  • 19

0 Answers0