简体   繁体   English

Azure 通知中心,ios 返回“提供的通知负载无效”

[英]Azure Notification Hub, ios returning "The supplied notification payload is invalid"

Following example Azure Notifications to React Native以下示例Azure 通知 React Native

Android works, but no matter what payload I pass to SendAppleNativeNotificationAsync I get the same error Android 有效,但无论我将什么负载传递给SendAppleNativeNotificationAsync ,我都会收到相同的错误

Unexpected error sending notification:  The supplied notification payload is invalid

I've even passed a simple string such as this我什至传递了一个像这样的简单字符串

iOSPayload = "{\"aps\":{\"alert\":\"Notification Hub test notification\"}}"
_hub.SendAppleNativeNotificationAsync(iOSPayload, tags, token)

The escaped quotes seem ok to me, but even with any other combination its not working.转义引号对我来说似乎没问题,但即使使用任何其他组合也不起作用。

The error may occur if payload is malformed.如果有效载荷格式不正确,则可能会发生错误。 You may want to know that the standard way to send push notifications is to send, for each notification that is to be sent, a specific payload to platform notification services (WNS, APNS).您可能想知道发送推送通知的标准方式是为每个要发送的通知发送一个特定的负载到平台通知服务(WNS、APNS)。

For example, to send an alert to APNS, the payload is a JSON object of the following form:例如,要向 APNS 发送警报,有效负载是 JSON object,格式如下:

{"aps": {"alert" : "Hello!" }}

When using concatenation, the entire expression must be surrounded with {}使用连接时,整个表达式必须用{}包围

Check this document on Notification Hubs Templates for more details on this.查看有关通知中心模板的此文档以获取更多详细信息。

Also check this similar SO thread might be helpful.还要检查这个类似的 SO 线程可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM