I am having an issue with FireBase Cloud Messaging in which I get the Token from the device and send the notification test through the Google Firebase notification console h
google apis are to be honest full of sh*. They randomly dont work with no means of debugging
If you have just added FCM to an existing app, onTokenRefresh()
will NOT be called. I got it to run by uninstalling the app and installing it again.
I've been working through this entire post and others as well as tutorial videos without being able to solve my problem of not receiving messages, the registration token however worked.
Until then I had only been testing the app on the emulator. After trying it on a physical phone it instantly worked without any prior changes to the project.
In my case, I just turn on WIFI and mobile data in the emulator and it works like a charm. cause I can't send comments, post a reply. Good luck
I had this problem, I checked my code. I tried to fix everything that was mentioned here. lastly the problem was so stupid. My device's Sync
was off. that was the only reason I wasn't receiving notifications as expected.
I had a similar problem, but in my case I was missing the google-services plugin from my Gradle build (I was adding Firebase to an existing project).
I added the following to my root build.gradle
:
classpath 'com.google.gms:google-services:3.1.0'
and the following to the end of my app
-level build.gradle
:
apply plugin: 'com.google.gms.google-services'
I then had to download the google-services.json
file from the Firebase Console (having originally imported an existing Google Cloud project) and copy it to my app
directory`.