While upgrading my Flutter packages I ran into an issue while testing
firebase_messaging on Android. When I ran the app in debug mode I could retrieve an FCM token without issue. However, when I would build for release I couldn’t get an FCM token at all. The more I dug into it I finally pinpointed that
firebaseMessaging.getToken() would hang forever and never resolve a token.
After a couple of days poking around at this problem, it finally dawned on me that I use an upload key and let Google manage my deployment key. If you are unfamiliar, you must upload your key’s SHA-1 signature to the Google console for several APIs to work correctly. In my case I was building for release on my local machine which uses my upload key, not the deployment key, therefore the SHA-1 was different than the APK that is downloaded from the Play Store! I simply added the SHA-1 from my upload key to the Google API console and I was good to go!
If you are using
API restrictions you will also want to check that you have enabled the correct APIs. Be sure you checked
Firebase Installations API and
FCM Registration API. Of course, this is in addition to having your apps SHA-1!
Tips Appreciated! ☕️ Cheers!