5

Been wondering how Firebase knows which user the device belongs to after app has been deleted?

Even after I delete the app, when I install it again, it knows the user.

I can't find in the documentation anything about this.

WYS
  • 1,637
  • 2
  • 16
  • 37
  • you mean you want to delete use for ever on uninstall? – Nitin Gohel Apr 09 '16 at 09:45
  • I'm just thinking it would be standard behaviour when the app is uninstalled, but it can still remember the user id. I can use unauth() to forget user, but I want to know where Firebase saves this info and how it does it. – WYS Apr 09 '16 at 09:46
  • When you say 'it knows the user' what does that mean? Firebase only knows a user when they authenticate as each user has a unique identifier (authData.uid). There are some other variables but please expand the question with specifics. – Jay Apr 09 '16 at 13:36
  • Firebase persists the authentication state in the keychain. This is not removed when the app is uninstalled. See [this answer](http://stackoverflow.com/questions/27893418/firebase-deleting-and-reinstalling-app-does-not-un-authenticate-a-user) for more information. – Frank van Puffelen Apr 09 '16 at 14:33

1 Answers1

1

Firebase does not watch on user uninstall app or install app and that saved the data based on it's backend. You need to do code for all the funtional work based on firebased API.

https://www.firebase.com/docs/ios/api/#firebase_createUserpasswordwithValueCompletionBlock

https://www.firebase.com/docs/ios/guide/login/password.html

enter image description here

Following its a Sample code:

let ref = Firebase(url: "https://<YOUR-FIREBASE-APP>.firebaseio.com")
ref.removeUser("bobtony@example.com", password: "correcthorsebatterystaple",
    withCompletionBlock: { error in
    if error != nil {
        // There was an error processing the request
    } else {
        // removed successfully
    }
})

So you need to add one button called Delete user or Remove user and on that button action you need to fire above code for delete user from firebase database. So when user install app again and try to login there recored not found and user need to register again with your app to logged in back.

Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144