3

I'm migrating an existing application from GCM to FCM, which wasn't too big on an issue and I was able to obtain the token with my debug builds. However, when I compile and sign the app with the production key, onTokenRefresh() is not called.

Here is what I've done:

  • There is a firebase app set up with my SHA1 signature of production key
  • The app in firebase it is setup with the correct package name
  • When production app is installed and opened it prints some logs, the app id in those logs matches the app in firebase dashboard
  • I checked the signature of the compiled apk and it matches my SHA1
  • I decompiled the app and the manifest in-fact contains the FirebaseMessagingService exported service that is auto generated by firebase.
  • I removed my SHA1 signature from all other apps
  • I fully removed the app from my phone
  • I am NOT using an emulator
  • I verified everything is configured correctly (in works in debug builds)
  • I tried changing network, did not generate the token
  • I did updated google-services.json file
  • I tried cleaning the project

non of the above resolved the problem, any suggestions?

Kirill Kulakov
  • 10,035
  • 9
  • 50
  • 67
  • Possible duplicates https://stackoverflow.com/a/37465575/2354845 – Badr May 03 '18 at 15:12
  • Updated everything I've tried, all the suggestions in this post did not resolve the issue for me. – Kirill Kulakov May 03 '18 at 15:18
  • I think the problem is related to the way you have generated the SHA-1 fingerprint. You've created a debug Keystore which works fine on debug mode instead of a release keystore for the release mode. – Badr May 03 '18 at 15:44
  • Do you know what the token was from the debug version? And have you called `String myToken = FirebaseInstanceId.getInstance().getToken()` to see if it matches the release version? – Barns May 03 '18 at 15:58
  • @badr I've a different package name and key store for my debug builds, I've done the setup for the debug build and it worked. I've generated this key for other apps, I'm confident I generated the correct key, In addition, I also verified the key of the compiled app and those are slightly different processes – Kirill Kulakov May 03 '18 at 16:03
  • @barns what do you mean what the token was? Yes I call it within the `onTokenRefresh()` however the prod build does not trigger `onTokenRefresh()` so the `getToken()` is never called. – Kirill Kulakov May 03 '18 at 16:06
  • 1
    `onTokenRefresh()` is only called when the token actually changes. So if it does not change it will not be called. `String myToken = FirebaseInstanceId.getInstance().getToken()` can be called anywhere in your app code at anytime. If you know what the "old" token was, then you can compare it to the one of your "release" version. If it is the same, then you know why `onTokenRefreash()` is not being called. – Barns May 03 '18 at 16:12
  • 1
    @Barns turns out it is, if I call the `getToken` directly it works, I found some application logic that resulted in me thinking that a token is not generated – Kirill Kulakov May 03 '18 at 19:10

0 Answers0