I have FirebaseMessagingService class to generate FCM token on function onNewToken()
. Some devices will get a token when its fresh installed or after app updated. But on some device, onNewToken()
return empty token.
When the app doesn't have a token, so I put this code to generate FCM token :
FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->
if (!task.isSuccessful || task.result.isNullOrEmpty()) {
FirebaseCrashlytics.getInstance().recordException(Throwable(task.exception))
}
}
I checked on the crashlytics, lot of devices are not getting the FCM token even the devices have Google Play service in it. The exceptions are variative. Here is exception from the crashlytics :
- java.io.IOException: SERVICE_NOT_AVAILABLE
- java.io.IOException: AUTHENTICATION_FAILED
- java.io.IOException: PHONE_REGISTRATION_ERROR
I also put
GoogleApiAvailability.getInstance().makeGooglePlayServicesAvailable(this)
but still not working
Anyone have a same problem?