it gives the token but it doesn't go to onTokenRefresh() which i need to trigger my sendRegistrationToServer().
onTokenRefresh in FirebaseInstanceIdService is only called when a new token is generated. If your app was previously installed and generated a token then onTokenRefresh would not be called. Try uninstalling and reinstalling the app to force the generation of a new token, this would cause onTokenRefresh to be called.
Also be sure that your FirebaseInstanceIdService is properly defined in your AndroidManifest.xml
thanks for your reply.It work.
Thanks Kroikie Bro, Its Work
Sorry, for my bad english.
My token doesn't go to onTokenRefresh()
I'm already add that service into manifest and also unistalling that application.
But onTokenRefresh() never trigger.
How to solve this ? Please help me.
@kroikie Thanks for your reply
The bug still exists. It's very strange I need to ask my users to reinstall app.
Its really strange that this topic is closed but in my app onTokenRefresh() is not getting called even after the reinstallation
@comm1x the recommendation of uninstall and reinstall is only for development, this is not a solution for an app that is already in the hands of users. You are able to call FirebaseInstanceId.getInstance().getToken(); at any time to get the current token.
@thewijaysharma please ensure that your FirebaseInstanceIdService is correctly defined in your manifest.
what if users have already installed the app and in a new update we need to implement FCM??
@sakshamsd in that case you would get the same callbacks as if the app had been initially installed.
I tried implementing FCM on app updates but I can't get any token. What
should be done??
On Wed, Jun 27, 2018, 9:17 PM Arthur Thompson notifications@github.com
wrote:
@sakshamsd https://github.com/sakshamsd in that case you would get the
same callbacks as if the app had been initially installed.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/quickstart-android/issues/23#issuecomment-400718414,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AbhOV3TSf5ggk9Hp1zgCixJzx41kyOInks5uA6VygaJpZM4InNzK
.
I have uninstalled app and installed again, but onTokenRefresh is never called.
I am using Firebase 11.4.2 in Android studio 3.1.4.
classpath 'com.google.gms:google-services:3.3.0'
@sakshamsd and @mob-rockstar could you try using the latest SDK 17.3.0 and also be sure that you are extending the FirebaseMessagingService and overriding onNewToken.
Can someone give us a solution for this? onNewToken is not getting called or initialized. Thus not getting the token to test the notification service in Firebase console.
Using:
action android:name="com.google.firebase.MESSAGING_EVENT" under intent-filter of a service.
in class:
@Override
public void onNewToken(String s) {
super.onNewToken(s);
Log.e("newToken", "newToken: " + s);
sendRegistrationToServer(s);
SharedPreferences pref = getApplicationContext().getSharedPreferences(FCMNotificationVariables.SHARED_PREF, MODE_PRIVATE);
pref.edit().putString("regId", s).apply();
}
Log e -> "newToken" is not found in the logcat console, thus seems like onNewToken() is not even called/intialized :(
@ksurya28995 onNewToken is only called when a new token is created. Try uninstalling the app and reinstalling, this will force the generation of a new token and you should see the token in the log.
@ksurya28995 I've had the same problem. What I've seen is that, after the app is installed, Google/FCM may issue a new token and you will NOT get a callback to FirebaseMessagingService#onNewToken executed. That leaves any notification-sending backend with the old token, which will fail when sending via FCM. To remedy this, whenever a new screen is displayed, I request a token using FirebaseInstanceId.getInstance().getToken(). If the token has changed, I update my notification-sending backend. It's not the ideal solution, as notifications send by my backend will be undeliverable until the user navigates to a new screen. But it's the best I could think of.
Having same issue here.
Service is registered on the AndroidManifest (as it should be), but onNewToken doesn't get called. I'll have to work around same way as @lgtout did.
After two days of troubleshooting, finally i found out that the latest versions of the below nuget packages (or may be one of them) is causing this. I downgraded to the below versions and it started working.
Xamarin.Azure.NotificationHubs.Android -> v0.6.0
Xamarin.Firebase.Messaging -> v71.1740.0
Xamarin.GooglePlayServices.Base -> v71.1610.0
Most helpful comment
onTokenRefresh in FirebaseInstanceIdService is only called when a new token is generated. If your app was previously installed and generated a token then onTokenRefresh would not be called. Try uninstalling and reinstalling the app to force the generation of a new token, this would cause onTokenRefresh to be called.
Also be sure that your FirebaseInstanceIdService is properly defined in your AndroidManifest.xml