Forum Xamarin.Android

Handling FCM notifications with notification payload, when the app is in background/killed?

I am using AppCenter to send notifications for my Xamarin.Forms application. AppCenter is sending these notifications through Firebase-Cloud-Messaging service to Android devices. I need to handle incoming notifications without the user clicking the notification.

I already have read this SO question and the accepted answer and as it says to handle notifications when the app is killed or in background, we have to send the firebase notification with the datapayload. But with AppCenter you can't send messages with 'data' payload (

So I have tried adding a Service which extends the FirebaseMessagingService and onMessageReceived(RemoteMessage remoteMessage) is only called when the app is in the foreground.

Now I'm looking for a way to handle notifications with a custom-service or something similar. In this SO question (, someone has already mentioned that they already implemented it.

@annihil we ended up having to create our own implementation of a BroadcastReceiver and JobIntentService to receive the FCM messages and explicitly pulling out the intent filters which sent the messages to the FCM classes shipped w/ their SDK – Jake Hall Jan 30 '18 at 11:58

I have been working with Xamarin.Forms and just a newbie for android development. So is it possible to do it without FirebaseMessagingService?


  • AnandmauryaAnandmaurya INMember ✭✭
    edited June 2019

    @tharindu_mp Without service class as you mention "FirebaseMessagingService" notification will not work in Xamarin Android . Second thing You need to implement BroadcastReceiver in proper way for handle new OS above 7. And add IntentFilter dynamically for BroadcastReceiver.

  • tharindu_mptharindu_mp Member ✭✭

    @Anandmaurya Do you mean is it necessary to have a service class extending FirebaseMessaginService class to handle notifications?
    And what would be the intent filter for the broadcast receiver in this case?

  • YelinzhYelinzh Member, Xamarin Team Xamurai

    what would be the intent filter for the broadcast receiver in this case?

    Add the following in AndroidManifest.xml.

            <action android:name="" />

    See the tutorial:

  • tharindu_mptharindu_mp Member ✭✭

    @yelinzh Can't register the MESSAGING_EVENT intent filter with a Broadcast receiver. (I have tried this one earlier)
    see this:

  • AnandmauryaAnandmaurya INMember ✭✭
    edited June 2019

    @tharindu_mp Yes , We need to use services for getting the notification in background. Use this link

    It will work for Android OS below version 8 and If you want to run this in above OS version (8 or 9). So only we need to change in Broadcast Receiver Intent Filter and notification Chanel. Add dynamically Intent Filter . eg.

    [IntentFilter(new[] { "GET_NOTIFICATION_INTENT" })]
    public class NotificationReceiver : BroadcastReceiver    

    NotificationReceiver is the class which is registering the notification in main class. Also add dynamic filter in main class.


    lf still you have any question let me know...

Sign In or Register to comment.