The anonymous provider allows you to sign in a user without requiring any credential, allowing them to use your application and create an account at a later point.
They can create a user at a later point by using the
of the anonymous user.
This method creates a new account in your Firebase Authentication system, except
in the case where there was already an anonymous user signed in into this app.
Access the signed-in user with
Anonymous users do not require any credential, and are useful in situations where you want to persist information about your users before asking them to sign in. For example, they may be useful when implementing a signed-out shopping cart in an e-commerce application.
Due to the unauthenticated nature of this kind of user, they are not transferrable across devices.
In order to allow your app's users to keep their information, ask them to provide
some other authentication credentials, and link them to the current user with
Log in to you Firebase console and go to the Authentication section of your application. Click on Sign-In Method and select the Anonymous provider and make sure it is enabled as in the screenshot below.
Signing the user in anonymously is a simple process of calling the
signInAnonymously() function and waiting for the result.
The event listener is called when there is a result from the sign in call. If the sign in was successful then you will have a valid signed in user.
A failed result generally indicates that there is an issue with your setup in the Firebase console,
you can check the
message for more information to determine the issue.
You can also listen to the global
FirebaseAuthEvent.AUTHSTATE_CHANGED event for the success of
signInAnonymously function, however to correctly process failed events you should use the