New Way to Implement Firebase Push Notification — FirebaseInstanceIdService Deprecated (Android)

New versions + New Implementation = Easiness

Image for post
Image for post

As we already know that to Implement the push notifications with firebase we always need to define the two services.

Now, In the new version of firebase-messaging, the firebaseInstanceIdService is Deprecated. In the new version we don’t need to use INSTANCE_ID_EVENT, just extend your MyInstanceIDListenerService service with FirebaseMessagingService like below:

Next Step is to @Override some methods:

public void onNewToken(String s) {
public void onMessageReceived(RemoteMessage remoteMessage) {

Visit my website at

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 like below:

<action android:name=""/>

If you want to get the token in your activity so in the older version we have:


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();

So, now you have the latest Implementation of Firebase push :-)

Sharing the knowledge is Caring 😊

If you want to learn some other topic then check it out the below link:

If you want to learn more about it then check it out the official link below:

Thanks for reading this article. Be sure to clap to recommend this article if you found it helpful. It means a lot to me.

If you need any help then Join me on , , , and Subscribe to my .

Senior Software Engineer(Android). Open Source Contributor, Technical Writer, Email: check my website at

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store