【问题标题】:Invalid tag for push notifications in Windows AzureWindows Azure 中的推送通知标签无效
【发布时间】:2023-04-02 02:32:01
【问题描述】:

我正在构建一个 Windows Phone 8.1 应用程序并希望添加来自 Windows Azure 的推送通知。我正在使用 CreatePushNotificationChannelForApplicationAsync 创建通道,然后获取生成的 URI 并将其存储在 Azure 数据库中。尝试使用 push.wns.sendToastText01 发送推送通知时,我在 Azure 日志中收到以下错误:

脚本“/table/Message.insert.js”中的错误。错误:400 - 提供了无效标签“https://db3.notify.windows.com/?token=AwYAAAC3tTi3W5ItZ0hWdZ3FLmELt%2flHcwpsM...”。有效的标记字符是字母数字、_、@、-、.、: 和 #。

我注意到频道 URI 包含没有出现在有效字符中的“%”,但这是在客户端应用程序中生成的 URI。我是否使用了错误的方法来发送推送通知,或者我还遗漏了什么?

编辑:我在 Azure 中使用 Node.js 作为后端。

request.execute({
                          success: function() {
                                push.wns.sendToastText01(channelUri, {
                                    text1: "Google Plus Friend Tracker",
                                    text2: item.content,
                                    param: '/ChatPage.xaml?friendGoogleId=' + item.author_id
                                })
                            }
                        });

【问题讨论】:

  • 你能说得更具体点吗?你在使用 JS 后端吗?能提供一些sn-ps的代码吗?
  • 感谢您的回复,我已经更新了我的问题。

标签: push-notification windows-phone-8.1 azure-mobile-services


【解决方案1】:

查看wns object documentation,第一个参数将是您要发送到的标签。由于您在上面的代码中提供了一个频道,因此您会收到指定的错误。

后端不需要提供通道 URI,因为它通过客户端注册操作与通知中心相关联。如果您正在广播消息,则只需提供 null 作为标记值。否则,您可以使用注册频道 URI 时指定的标签。

有关该过程的更多信息,请参阅"Get started with push" 教程。 "Send push notifications to authenticated users" 教程中还有一个使用标签(用户 ID)的示例。有关标签的更多信息,Notification Hubs breaking news tutorial 也不错。

【讨论】:

    猜你喜欢
    • 2020-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-16
    • 1970-01-01
    • 1970-01-01
    • 2019-06-23
    相关资源
    最近更新 更多