What happens to Firebase anonymous users?

前端 未结 3 1569
囚心锁ツ
囚心锁ツ 2020-12-08 06:33

I want to know what will happen to the users of my app that I used anonymous sign in method for them.

The Firebase documentation is really BAD and didn\'t explain ev

相关标签:
3条回答
  • 2020-12-08 06:50

    If you'd like anonymous users to be removed from your user list, you'll have to write a service to do that for you.

    Since firebase doesn't provide a way to list registered users, you'll have to make sure you're storing some sort of user list in the database. You can then use the node.js admin sdk to get user data, check if the user is anonymous, and find when the user was created. For performance reasons, you may wish to store this information in a special area of your database and retrieve it all at once. Once you've identified a stale anonymous user they can be easily deleted.

    0 讨论(0)
  • 2020-12-08 07:07

    Anonymous users don't expire, and there isn't currently any automated way to purge them.

    Firebase doesn't automatically remove them because it doesn't really know if a user is still storing data linked to that login - only the app creator does. Imagine if you are playing a puzzle game on your phone, and get to level 100. Then when you go to play level 101 next year, all progress is lost. Firebase can't just assume a user being inactive for a year means that the account can be removed.

    There is a couple tools that should help, though.

    1) Admin SDK & Firebase CLI list users.

    2) Linking multiple auth providers

    3) Auth State Persistence

    Once you list your users, you can check that each doesn't have any other providers, and hasn't been used recently, doesn't have data stored, and delete them.

    Better, though, would be to ensure that only one account is created per user. If you create an anonymous account to help users store data before logging in, you may want to consider prompting them to link a auth provider (like Google or email). If you link the account, rather than creating a new one, you'll avoid abandoned accounts from active users.

    In general, you will also want to make sure to use auth state persistence to ensure that there aren't more accounts than necessary being created. Creating 1 account per new visitor, rather than 1 per time someone repeatedly visits your page, will significantly help keep user growth in check.

    0 讨论(0)
  • 2020-12-08 07:14

    In my case, I am using the anonymous sign-in method for authentication without the knowledge of the user. Each time when the user leaves the app, delete the anonymous user by -

    FirebaseAuth.getinstance().currentuser?.delete()
    

    There will be no stacking up of anonymous user with this and limits the number of anonymous user in the app

    0 讨论(0)
提交回复
热议问题