4

Originally, I had a working app and receiving push notifications successfully. I reorganized our project in firebase and we've deleted and re-added the app to the console (in the same project). I've redownloaded the google-services.json file and noticed a few things changed like the mobilesdk_app_id for the specific app package I'm testing.

If I do a clean install with the new changes I can successfully receive a push notification. However, if I install a previous version with the old google-services.json and upgrade without uninstalling first, I cannot receive any notifications. I also see that I do not get a callback for a new token in the FirebaseMessagingService -> onNewToken method after upgrading.

Is there a way to debug this issue? Can I force Firebase to give me a new token since the json file has changed? I'm sending these notifications from the console and targeting the correct app. I'm confused as to why a fresh install with the new json file works but upgrading from a previous version does not.

zkohi
  • 2,085
  • 1
  • 7
  • 17
kevskree
  • 3,532
  • 3
  • 22
  • 32
  • 1
    this is my problem and what I understand is google-service.json is not updating even if you replace it with old one, but don't know how to force replace it – vahid Sep 21 '20 at 03:20

1 Answers1

0

Upgrading an app doesn't trigger generation of a new firebase device token. So the old token is generated with the old google-services.json file and then a new token is never generated.

You could resolve this issue by simply uninstalling the app and reinstalling it, which causes a new token to be generated with the new google-services.json file.

But if you don't want to require your users to uninstall and reinstall your app, you can make use of FirebaseInstanceId.getInstance().deleteInstanceId(); followed by FirebaseInstanceId.getInstance().getToken(); in order to force the generation of a new token. You'll have to do this in a separate thread from the main thread. Follow the instructions at this stackoverflow answer

Steven Love
  • 143
  • 5