Resolved! FirebaseInstanceIdService is deprecated

So after updating the version of firebase-messaging in the build.gradle file from v17.0.0 to v17.1.0, strange things started happening…

there was a line of horror in service I used to use for messaging in my application. After some research, I landed on this page.

Let’s quickly go to updates which we need to do to get it working like before.

Now there is no need of FirebaseInstanceIdService to get token, so just delete it and also remove it from AndroidManifest.xml as well.

Method onTokenRefresh() is depriciated. Now we need to override onNewToken() method to get new token.

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    public void onNewToken(String token) {
        Log.e("Refreshed token:",token);

    public void onMessageReceived(RemoteMessage remoteMessage) {


Method getToken() which we used in Activity is also depriciated now. Use getInstanceId() as follow

FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener( MyActivity.this,  new OnSuccessListener<InstanceIdResult>() {
     public void onSuccess(InstanceIdResult instanceIdResult) {
           String updatedToken = instanceIdResult.getToken();
           Log.e("Updated Token",updatedToken);



I hope this will help in time of crises 😛

Leave a Comment

Your email address will not be published. Required fields are marked *