AppCenter:如何在Xamarin中检索`notification_content`对象的`name`属性?

问题描述 投票:0回答:1

我正在查看有关使用AppCenter发送推送通知的documentation。我能够成功创建和发送推送通知,但是我不明白为什么我们需要name对象中的notification_content属性。需要吗?谁使用它?

我问的原因是我想根据其类型在客户端设备上过滤掉通知。我希望为此目的使用name属性,而不是在custom_data中创建另一个属性。

在Android上,我可以像这样检索通知标题和文本:

var title = statusBarNotification.Notification.Extras.GetString("android.title");
var text = statusBarNotification.Notification.Extras.GetString("android.text");

还有一种方法也可以检索name属性吗?

android xamarin push-notification visual-studio-app-center
1个回答
0
投票

First无法从Notification接收name属性。

Send Notification document开始,name属性用于如下定义通知消息的名称。

{
  "notification_content": {
    "name": "First Push From App Center",
    "title": "Push From App Center",
    "body": "Hello! Isn't this an amazing notification message?",
    "custom_data": {"key1": "val1", "key2": "val2"}
  }
}
  • [name:定义通知消息的名称。

Second此属性仅用于App Center,您不能从通知数据如下图。

enter image description here

如果您在App Center中不使用API​​来查看有关发送通知的this document,您会看到广告系列名称是API中的name属性。

用广告的描述性名称填充广告系列名称字段。您提供的值将显示在App Center广告系列列表页面中。

它仅显示在App Center列表页面中,但是我也找不到其他API在App Center中获取此属性。

Finally,如果我们无法从Notification Data甚至App Center中检索到它,那么我建议您使用custom_data来定制所需的数据。

© www.soinside.com 2019 - 2024. All rights reserved.