Unregistered token error after sending one notification

I am facing this dramatic problem with my android app while using Firebase.
1. My app receives token on the first launch
2. I am able to send notification from firebase console to the registered token
3. If I try to send a notification again with the console just after step 2. It shows me “unregistered token” after 2nd attempt onwards.

I have all necessary configuration already there in the manifest and google service.json file is also in place with the correct configuration. I believe things are correct because the app is able to receive notification once and the problem starts coming only after that.

  • Android - offline, non-vector based, custom maps
  • Creating an android smart app banner
  • How to display custom view in ActionBar?
  • How to install trusted CA certificate on Android device?
  • How to increase hit area of Android button without scaling background?
  • Installation error: INSTALL_FAILED_OLDER_SDK
  • Update 1:
    If I uninstall app and reinstall it then also I am able to receive notification only once.

    Those who wants to look at the code, this is how I am getting token:

    public void onTokenRefresh() {
        //Getting registration token
         refreshedToken = FirebaseInstanceId.getInstance().getToken();
        //Displaying token on logcat
        Log.d(TAG, "Refreshed token: " + refreshedToken);

    This gets calls only first launch and after that, I haven’t seen it getting called (which I think is expected behavior).

    OnMessage received also gets called on first notification and then it never gets called off:

    public void onMessageReceived(RemoteMessage remoteMessage) {
        Log.d("FCM", "From: " + remoteMessage.getFrom());
        if (remoteMessage.getNotification() != null) {
            Log.d("FCM", "Notification Message Body: " + remoteMessage.getNotification().getBody());

    Update 2 :
    Tried to hit the HTTP api of FCM using the same server key and token and got following response:

      "multicast_id": 6286279702096230688,
      "success": 0,
      "failure": 1,
      "canonical_ids": 0,
      "results": [
          "error": "NotRegistered"

    Just to avoid cross questions here are few more details:

    • Android studio : v2.3.1
    • Google play service version : 10.0.1
    • Libraries included : core, database, storage, messaging – all is having same version as google play service 10.0.1

    Update 3 : Firebase crash, database and storage is working in the same project (which shows that google service.json file is correct).

    Please help me to get it fixed.

    Related posts:

    java.lang.IllegalArgumentException: AppCompat does not support the current theme features
    JPEG images have different pixel values across multiple devices
    How to apply android layout animation only to children above a certain index?
    Can I find the MAC address of my Access point in Android?
    How to use a function only if the version is 11+
    Android ListView fast scroll with sections: section text too long
  • Access to WebView from another function in MainActivity class
  • Difference between system.gc() and runtime.gc()
  • How to overlay an image or view on top of a camera captured image
  • actionbar search will not close after search
  • Genymotion devices not working in Eclipse on OS X Yosemite
  • Android: ListView.getScrollY() - does it work?
  • 3 Solutions collect form web for “Unregistered token error after sending one notification”

    The registration token may change when:

    • The app deletes Instance ID
    • The app is restored on a new device
    • The user uninstalls/reinstall the app
    • The user clears app data.

    you can see the documentation here

    and you can read here also about fcm errors
    this happens for debug mode only so you can call this method in your launcher activity this will accept the HTTPS certificate of Test/Development server, as the HTTPS certificate is invalid /not trusted
    In release it will be okay.

    private void RegisterFireBase()
    if (BuildConfig.DEBUG) {    
                Task.Run(() =>
                    var instanceId = FirebaseInstanceId.Instance;
                    Android.Util.Log.Debug("TAG", "{0} {1}", instanceId?.Token?.ToString(), instanceId.GetToken(GetString(Resource.String.gcm_defaultSenderId), Firebase.Messaging.FirebaseMessaging.InstanceIdScope));
                ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;

    I remember facing the similar problem before. Here is what I did and its working smooth for me. Hope this helps,

    PreferenceStore is a helper class to save, edit and delete shared preferences.

    public void onTokenRefresh() {
        String token = FirebaseInstanceId.getInstance().getToken();
        Log.i(TAG, "New FCM Token: " + token);
        setup_flag = PreferenceStore.getBoolean(getApplicationContext(), PrefKeys.IS_FIRST_FCM_TOKEN);
        if (!setup_flag) {
            // save token and boolean value in shared preferences for 
            // the first time you run the app after install
            PreferenceStore.saveString(getApplicationContext(), "FCM_TOKEN", token);
            PreferenceStore.saveBoolean(getApplicationContext(), "IS_FIRST_FCM_TOKEN", true);
        } else {
            // other time your app loads, update the token (like call the API endpoint).

    FCM is the opposite of GCM.

    While using GCM classes, the TokenID is refreshed every now and then thats why it is also updated in the Database on the server.

    While using FCM. FCM basic architecture works on unique TokenID, this is the reason that onTokenRefresh does not invoke multiple times. It only invokes once.

    What you have to do is just save your INITIALLY generated TokenID and utilize it accordingly.

    P.S: In FCM token does not refresh not until and unless the app is Reinstalled.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.