Stay Connected


FirebaseInstanceIdService is deprecated – Android

Recently Google pushed got many updates in dependencies of Firebase along with JetPack aka AndroidX. In the new version of firebase messaging the firebaseInstanceIdService is deprecated. Now we don’t need to use INSTANCE_ID_EVENT, just extend MyInstanceIDListenerService with FirebaseMessagingService. That means no need to use FirebaseInstanceIdService service to get FCM token.

We can safely remove FirebaseInstanceIdService service. Now only need to @Override onNewToken() get Token in “FirebaseMessagingService“.

public void onNewToken(String s) {
Log.d("FCM TOKEN "+s);
public void onMessageReceived(RemoteMessage remoteMessage) {

onNewToken will give you the token and onMessageReceived will received the message. Now no need to call onMessageReceived in another service. After all this, we also need to update the Manifest file as well and now only one service needs to be defined:

<service android:name=".service.firebase.MyInstanceIDListenerService" android:permission="false">
<action android:name=""/>

in the older version we get the token in activity by


The above method getInstance().getToken is also deprecated. The new way to get the token in your activity like below:

FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListenr(Activity.this,new OnSuccessListener<InstanceIdResult>() {


public void onSuccess(InstanceIdResult instanceIdResult) {

String newToken = instanceIdResult.getToken();



Adnan Sattar

A self-driven productive Software Engineer who thrives in highly pressurized and challenging working environments by constantly improving skills. Eager to grasp new ideas and concepts from the environment.

Leave a Reply

%d bloggers like this: