How constant is the Firebase Anonymous ID
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.
Is FirebaseUser.getUid() constant for a given user?
When you first verify the phone number (or first sign in with a social provider, or call createUser
), a user account is created - and thus a new unique UID id created. From that moment on, that user/phone number will remain associated with that account/UID. No matter if they re-verify on the same or a different device.
If you delete the account, a new account+UID will be generated when you use that same phone number next time.
Firebase - Should I stop using Anonymous Auth in my specific case? (Also, how to delete users)
You don't need to worry about this, Firebase authentication is independent of FCM; the only thing you may need to worry about is token expiration (covered in this question).
So yeah, you can drop anonymous authentication, no problem if the session expires.
Firebase authentication without user's credentials
What you're looking for is Firebase's anonymous authentication. This signs the user into Firebase, without requiring them to enter credentials.
If needed you can later allow the user to sign-in with a supported provider, and link that to their existing (anonymous) account.
Does Firebase anonymous authentication survive when clearing app cache?
No, it will not survive. No data previously saved by the app will survive. The whole point of clearing app data is to make the app behave as if it was newly installed.
Keep Firebase authentication state across iOS devices
There is no way to retain Firebase's anonymous authentication state across app installs, or across devices. The anonymous user's token cannot be restored once it's deleted, and cannot be recreated on another device.
If you need this functionality, consider implementing your own custom identity provider in Firebase Authentication, that for example uses the Apple Id of the user as their identity. This will take part in your client-side code and in a server-side component.
Related Topics
How to Capture Depth Data from Camera in iOS 11 and Swift 4
Difference Between String Interpolation and String Initializer in Swift
How Is Optional Binding Used in Swift
How to Detect Absent Network Connection When Setting Firestore Document
Swift 4.0 Mapview Running Slow
Segue from a Slpagingviewswift Vc and Dismiss the Destination Vc to Return
Getting Dyld_Fatal_Error After Updating to Xcode 6 Beta 4 Using Swift
Swiftui: Prevent Image() from Expanding View Rect Outside of Screen Bounds
Checking If Textfields Are Empty Swift
Swift 2 Protocol Extension Not Calling Overridden Method Correctly
Why I Can Change/Reassigned a Constant Value That Instantiated from a Class
Function Throws and Returns Optional.. Possible to Conditionally Unwrap in One Line
What Is the Way to Save Fonts and Sizes in Firebase for Textview Swift