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

Xamarin android-How to detect deliver event of deliver FCM foreground messages

我已经在 Xamarin android 应用程序中实现了 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",

}
}

我在这里回答我的问题。问题是,在发送通知时,我有 notification 负载和 data ,如果应用程序在前台 OnMessageReceived 不会在这种情况下调用。如果你需要调用OnMessageReceived总是不要发送notification payload,我们只需要发送data消息。谢谢