1

I have a server, which is going to get Firebase Instance Id + application data from all my users devices, and store them in MySQL.

@Override
public void onTokenRefresh() {
    // Get updated InstanceID token.
    String refreshedToken = FirebaseInstanceId.getInstance().getToken();
    Log.d(TAG, "Refreshed token: " + refreshedToken);

    // If you want to send messages to this application instance or
    // manage this apps subscriptions on the server side, send the
    // Instance ID token to your app server.
    sendRegistrationToServer(refreshedToken, applicationData);
}

Time to time, user is going to refresh new Firebase Instance Id, and send it to server again.

We can imagine as time goes on, MySQL is going to have a large set of "invalid" Firebase Instance Id.

I have another daily cron job, which is going to perform processing on every row of application data, and send notification to user based on processing result. The notification will be sent via Firebase Instance Id.

I was wondering, what is the common best practice, to clean up "invalid" Firebase Instance Id?

My plan is the run a daily (or hourly) cron job, check on Firebase Instance Id validity using How to verify FCM registration token on server? . If that row is containing invalid Firebase Instance Id, removal on that row will be performed.

I was wondering, is this a good way to do so?

Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875

0 Answers0