In my MainActivityin my log, I can see the token using FirebaseInstanceId.getInstance().getToken() and it display the generated token. But it seem
There are several reasons to not calling the onTokenRefresh methon not called. I have listed that and mention it one by one .
Please make sure you have added the internet permission
check have you added the google-services.json file that generate from google console inside of app directory in your project
apply plugin: 'com.android.application' android { // ... } dependencies { // ... implementation 'com.google.firebase:firebase-core:16.0.4' // Getting a "Could not find" error? Make sure you have // added the Google maven respository to your root build.gradle } // ADD THIS AT THE BOTTOM apply plugin: 'com.google.gms.google-services'
4) add the play service class path in project level build.gridle file
buildscript { // ... dependencies { // ... classpath 'com.google.gms:google-services:4.1.0' // google-services plugin } } allprojects { // ... repositories { // ... google() // Google's Maven repository } }
5) Make sure you have added those service in the AndroidManifes file inside application tag
6) onToken refresh is called when token refresh and when install the app for the first so make sure you have deleted the app manually or clear the data
7) Make sure you have extends the FirebaseMessagingService in your service class
[Note : If its not working only for specific version for example android kitkat version then try to change the fcm version.]