Xamarin android-如何检测传递FCM前台消息的传递事件

时间:2018-01-30 15:05:17

标签: xamarin.android firebase-cloud-messaging foregroundnotification

我在Xamarin安卓应用中实现了FCM通知。当提供它的前台通知未调用OnMessageReceived事件时。如何获取前台消息传递事件。

使用Postman发送FCM消息的代码

{ 
 "to":"eXj6c43Jueu6pZ7J6nlPJk81plm5UGjNAwzEGDMM2WQa3EBSxJ-85GDn09wqJ6mE4Jq5nkJ1Qdo", 
 "notification" : {
 "body" : "New homework assigned",
 "OrganizationId":"619",
 "click_action":"SISActivity",
 "content_available" : true,
 "priority" : "high",
 "title" : "KG school",
 "bodyText" : "great match!"
 },
 "data" : {
 "OrganizationId":"6166",
 "moduleName":"Homework",
 "bodyText" : "New homework assigned",

}
}

1 个答案:

答案 0 :(得分:1)

我在这里回答我的问题。问题是,在发送通知时,如果notification有效负载与data一起使用,则前台OnMessageReceived中的应用将不会在此方案中调用。如果您需要致电OnMessageReceived,请务必不要发送notification有效负载,只需发送data消息即可。谢谢