我正在尝试从通知中获取数据,当我的应用程序关闭时以及当应用程序处于后台时。我收到通知,点击它,然后在 MainActivity(来自 android 项目)中我想获取数据。 我可以在我的应用程序打开时通过 HmsMessageService 和 OnMessageReceived 来完成,没有问题。但我找不到示例,如何在应用程序关闭时执行此操作。任何帮助,请。 在 Json 中有我的通知:
var jObject = new
{
message = new
{
notification = new
{
title = titleNot,
body = bodyNot
},
android = new
{
notification = new
{
foreground_show = false,
click_action = new
{
type = 3
}
}
},
token = new[] { token }
}
};
最佳答案
应用关闭时,可以通过自定义click_action
获取参数。
在您的应用服务器上的消息正文中设置意图。
{
"message": {
"notification": {
"title": "message title",
"body": "message body"
},
"android": {
"notification": {
"click_action": {
"type": 1,
"intent": "intent://com.huawei.xahmspushdemo/deeplink?#Intent;scheme=pushscheme;launchFlags=0x4000000;i.age=180;S.name=abc;end"
}
}
},
"token": [
"pushtoken1"
]
}
}
这是 document .
关于c# - 华为。使用 Push Kit 从通知中获取数据(标题、正文、发送时间)。 Xamarin 表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70365046/