I'm building an app with Firebase Real-Time Database. The app will be mainly offline at first, but we are planning an online update later. I'm planning to use the anonymous sign in, to get an ID for the user and store all his data under this ID:
Auth.auth().signInAnonymously(completion: { (user, error) -> Void })
After signing in I get an ID that looks like something like this: pCfgFOvEYEYvfWHaaaaavKgs8h33
Is it guaranteed that this ID will ALWAYS stay unchanged on a given device? I couldn't find any documentation about this.
The format of the auth UIDs generated by Firebase will be changing on Monday, August 17th. We'll be changing from an incremental integer to a UUID (universally unique identifier).
You can use Firebase Authentication to create and use temporary anonymous accounts to authenticate with Firebase. These temporary anonymous accounts can be used to allow users who haven't yet signed up to your app to work with data protected by security rules.
No its safe to use the uid and recommended, firebase uses auth to authenticate the user and the assign the uid to identify the user across firebase. You will be using uid in your security rules and as well as to identify user info in your db records.
Note that Firebase Auth web sessions are single host origin and will be persisted for a single domain only. Indicates that the state will only persist in the current session or tab, and will be cleared when the tab or window in which the user authenticated is closed. Applies only to web apps.
A user's UID never changes. So after you sign in a user anonymously, the UID will remain the same (even when you call signInAnonymously
again), until you call signout
, or until the user uninstalls the app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With