FirebasePushNotificationPlugin(xamarin) - 应用程序在后台时不会触发事件(android)

Fet*_*mos 5 android push-notification xamarin.android firebase xamarin.forms

我将此插件用于我的 Xamarin Forms 应用程序(android)。当应用程序在后台时不会触发任何事件。事件在应用程序处于前台时起作用。但是应用程序是后台任何未触发的事件,该应用程序才刚刚打开。但是我需要将消息参数传递给应用程序。我不确定这是否是一个错误,也许这是我的错误。我将不胜感激任何帮助。我使用这个 api 发送消息:

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

这是我的有效载荷:

  {
 "data": {
    "id_serv" : "12",
    "id_group" : "1",
    "click_action":"Accept"
  },
  "notification" : {
     "body" : "test",
      "title" : "test"
 },
 
 "priority": "high",
  "condition": "'g1' in topics"
 }
Run Code Online (Sandbox Code Playgroud)

我还订阅了所有可用事件 - OnNotificationAction、OnNotificationOpened、OnNotificationReceived。我也尝试在 android 级别订阅,但这也不起作用。有什么帮助吗?

The*_*ude 1

当应用程序在后台时,Firebase 使用其通知系统,这样您的代码就不会被调用。

如果您希望调用您的代码,您需要仅通过数据对象传递数据,而不使用通知对象。

所以你的通知对象需要像这样:

"data": { "id_serv" : "12", "id_group" : "1", "click_action":"接受", "body" : "测试", "title" : "测试" },

“优先级”:“高”,“条件”:“主题中的'g1'”}

更多信息请参见:FB 接收消息