Android - Automatically delete inactive users from Firebase Auth

Viewed 292

I like to automatically delete the user authentication and user info in the database if they have not logged in for say,a month or a year. This is to prevent inactive accounts from taking up space in Firebase.

Is there any way to do that.

1 Answers

You will need two things:

  1. Create a way to identify old user accounts. You can store a timestamp in your database that records the time of last activity of that user.
  2. Write some backend code to query for and delete the accounts.

#1 might require some code in your app to write the current time every time the user launches the app.

#2 requires that you use use the Firebase Admin SDK to delete user accounts that you discover using a query for data that you created in #1.

If you do not have data from #1, you will have to list all user accounts using the admin SDK, then figure out which ones need to be deleted.

Related