【问题标题】:Azure Notifications hub format tags payload REST APIAzure 通知中心格式标记有效负载 REST API
【发布时间】:2017-06-22 00:48:15
【问题描述】:

我有一个连接到数据库的普通 C# MVC 网站,我正在存储我的手机应用程序推送 ID。

我使用这些推送 ID 并想向它发送推送。 我可以通过将值插入到那里的标记字段中,使用 Microsoft Azure 网站上的发送测试推送功能手动执行此操作。

但现在我想使用我网站上的 REST API 来实现。

我在 .NET 示例中遵循了这个

https://github.com/Azure/azure-notificationhubs-samples

Android 的有效载荷如下所示:

{\"data\":{\"message\":\"" + message + "\"}}

我尝试通过这样做将标签添加到有效负载:

{\"data\":{\"message\":\"" + message + "\"}, \"tags\":{\"DeviceToken\":\"the push ID here\"}}

但它没有用。推送已发送给所有人。

您如何使用或格式化 REST API 中的标签?

解决方案:

headers.Add("ServiceBusNotification-Tags", recipient);

在我的例子中接收者是安装ID

【问题讨论】:

    标签: c# .net rest azure azure-notificationhub


    【解决方案1】:

    根据您的描述,我检查了 REST API Send a GCM Native Notification 并按照 azure-notificationhubs-samples 测试了这个问题。为了给你的payload添加标签,你可以指定ServiceBusNotification-Tags header。我向一组标签(游戏、新闻)发送了 GCM 原生通知,您可以参考:

    此外,您可以利用Microsoft.Azure.NotificationHubs 发送推送通知。更多详情可以参考这位官方document

    【讨论】:

    • 让它适用于 iOS 推送,但不适用于 Android。我相信问题可能是我没有正确保存 Android 标签。
    猜你喜欢
    • 2014-04-10
    • 1970-01-01
    • 2017-08-29
    • 1970-01-01
    • 2015-08-09
    • 1970-01-01
    • 2020-10-04
    • 2018-01-26
    • 1970-01-01
    相关资源
    最近更新 更多