Asuwathaman R C
Asuwathaman R C

Reputation: 303

Android - Automatically delete inactive users from Firebase Auth

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.

Upvotes: 3

Views: 553

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317487

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.

Upvotes: 4

Related Questions