Search code examples
xamarinpush-notificationxamarin.android

Xamarin android push notification OnMessageReceived() event is not calling when app is on background or killed mode


I have a xamarin forms application and I implemented push notification on it. I want to navigate to different pages when user taps on the push notification depends on the notification data. So for that doing some codes in OnMessageReceived event and it's working as expected if app is open mode. But this event is not triggering on other modes, please help me on this. I refer this link to implement push notification ,pushnotification on xamarin forms.

Here is my json payload for android.

{
  "notification": 
           { "title" : "Sample App", "body" : "New items are available"},
  "data" : 
        {"Id" : "876df123", "pageName" : "ClothingsPage" } 
}

Solution

  • Changed the notification payload to the below format, after that it worked.

    {"data" : {"Id" : "123456", "body" : " test mobile app", "title" :  "SampleTest" } }