FetFrumos
FetFrumos

Reputation: 5954

FirebasePushNotificationPlugin(xamarin) - events not fire when app in background(android)

I use this plugin for my Xamarin Forms app(android). Any event not fire when app is in background. Events work when the application is in the foreground. But app is background any event not fire, the app is just opening. But I need to pass the message parameters to the application. I'm not sure if this is a bug, maybe this is my mistake. I will be grateful for any help. I use this api for send message:

https://fcm.googleapis.com/fcm/send

This is my payload:

  {
 "data": {
    "id_serv" : "12",
    "id_group" : "1",
    "click_action":"Accept"
  },
  "notification" : {
     "body" : "test",
      "title" : "test"
 },
 
 "priority": "high",
  "condition": "'g1' in topics"
 }

I also subscribe to all available events - OnNotificationAction, OnNotificationOpened, OnNotificationReceived. I also try to subscribe at the android level, but this also does not work. Any help?

Upvotes: 5

Views: 820

Answers (2)

Shahriyar Aghajani
Shahriyar Aghajani

Reputation: 403

i don't know anything about xamarin, but in firebase version above 16, you just got push notification data when app is running, when app is killed: after click on notification, android open your first activity with bundle (extra data), and you must get this data and use them, so debug your app and check your first activity bundle after clicking on notification

Upvotes: 0

The Dude
The Dude

Reputation: 365

When the app is in the background firebase use their notification system that way your code not called.

If you want that your code will be called you need to pass the data through the data object only and not use the notification object.

so your notification object need to be like that:

"data": { "id_serv" : "12", "id_group" : "1", "click_action":"Accept", "body" : "test", "title" : "test" },

"priority": "high", "condition": "'g1' in topics" }

More info here: FB Receive massages

Upvotes: 1

Related Questions