Skip to content Skip to sidebar Skip to footer

Why Not Getting Android Firebase Fcm Registration Token?

I'm trying to send a push notification to my app from my app server but i'm not getting the FCM registration token through FirebaseInstanceIdService. Here i'm using Genymotion pers

Solution 1:

Main Problem is Uninstall first your apk app from your mobile then run and build again from android studio. It helps for me

If google play services are installed and you are still not getting the token then probably you have implemented your SharedPreferences inside onTokenRefresh() after the token has been generated. The problem would have been solved automatically if the Application is reinstalled. Remember the onTokenRefresh() callback fires whenever a new token is generated. So if the token is already generated onTokenRefresh() won't get called. Only when the token has changed onTokenRefresh() method will get called. You can always get the generated token value by calling FirebaseInstanceId.getInstance().getToken(); almost anywhere in your Application. For your case only you can retrieve the token from SharedPreferences as follows:-

SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(getString(R.string.FCM_PREF), Context.MODE_PRIVATE);
            final String token = sharedPreferences.getString(getString(R.string.FCM_TOKEN),FirebaseInstanceId.getInstance().getToken());

This will ensure that you are always getting the token, and if the token changes onTokenRefresh() will get called and your SharedPreferences will get updated.

Solution 2:

It happen because Genymotion have not google play services by default.

Solution 3:

Follo the further instructions to install Google Services on Genymotion, it will take only 10 minutes only

How to install Google Play Services in a Genymotion VM (with no drag and drop support)?

Solution 4:

If you already added the service in your manifest file then you are right it's happening cause of you Genymotion emulators API, then Check this answer

Post a Comment for "Why Not Getting Android Firebase Fcm Registration Token?"