1
votes

I am integrating FireBase Push Notification into my application. Although I am receiving push notifications(when application is in background) but my onMessageReceived(RemoteMessage remoteMessage) is never called, independent of whether application is in foreground or backgroud. If its the issue with FCM or there is something that I am doing wrong. I am using 'com.google.firebase:firebase-messaging:9.0.0' in my app build.gradle. I have declared both the services in my application manifest

 <service
    android:name="app.pnd.camscanner.MyFirebaseMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>

<service
    android:name="app.pnd.camscanner.MyFirebaseInstanceIDService">
    <intent-filter>
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
    </intent-filter>
</service>
2
if onMessageReceived never gets called how do you know you get the push messages? - tyczj
Does MyFirebaseMessagingService extend FirebaseMessagingService? - Arthur Thompson
@ArthurThompson - Yes I have already extended FirebaseMessagingService in my FirebaseMessagingService service class - bhanu kaushik
To be clear, if your app is in the foreground and you send a message to it, you get nothing but if you app is in the background you get the notification? - Arthur Thompson
@ArthurThompson yes exactly - bhanu kaushik

2 Answers

1
votes

The issue for me was that i had tools:node="replace in the application tag in the manifest

0
votes

Finally, the issue has been resolved. I have created a new project and integrated the firebase again. Now, when the application is in background, I am getting the push automatically and when application is in foreground, my onMessageReceived(remoteMessage) of MyFirebaseMessagingService class which extends FirebaseMessagingService is being called in which I am generating the push notification by myself.