I followed the instructions on firebase.google.com to add FCM in my project.
Everything was fine, I've got the message "FirebaseApp initialization successful" and fresh token in my logs. But It's not working... Only the first push notification that I send to the token I get success. The second push and rest get error "NotRegistered".
Documentation says
If it is NotRegistered, you should remove the registration ID from your server database because the application was uninstalled from the device, or the client app isn't configured to receive messages.
but application wasn't removed and client app is configured to receive messages because the first message comes to the client
I struggled for hours but I found the problem. It was really hard to find and explain as well. I'll try:
My project has a dependency with another dependency inside that:
My project > Dependency > Sub-dependency
The sub-dependency contains an AndroidManifest.xml file with <application> tag. Something like that:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my_sub_library">
<application android:allowBackup="true">
</application>
</manifest>
Because of this application tag, my dependency needed to do it:
<manifest package="br.com.ilhasoft.support.databinding"
xmlns:tools="http://schemas.android.com/tools">
<application tools:node="replace"/>
</manifest>
My solution was to update sub-dependency by removing the application tag and update dependency removing the replace action.
Somehow, firebase was ignoring my FirebaseMessagingService and revoking my FCM registration token.
I suggest you check your dependencies to see which one has application tag and update/replace it. It worked for me!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With