首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过Push Toast推送windows Phone 8.1的Toast通知

通过Push Toast推送windows Phone 8.1的Toast通知
EN

Stack Overflow用户
提问于 2017-03-22 01:50:15
回答 1查看 94关注 0票数 0

我是windows phone开发和推送通知的新手。我已经在我的应用程序中实现了pushwoosh通知。我按照文档PushWoosh WP收到了通知,但通知栏上没有显示确切的通知文本。我只收到了“新通知”

这是我的代码。

代码语言:javascript
复制
 private async void OnPushNotification(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
    {
        String notificationContent = String.Empty;

        switch (e.NotificationType)
        {
            case PushNotificationType.Badge:
                notificationContent = e.BadgeNotification.Content.GetXml();
                break;

            case PushNotificationType.Tile:
                notificationContent = e.TileNotification.Content.GetXml();
                break;

            case PushNotificationType.Toast:
                ToastTemplateType toastType = ToastTemplateType.ToastText02;
                XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastType);
                toastXml = e.ToastNotification.Content;

                XmlNodeList toastTextElement = toastXml.GetElementsByTagName("text");
                toastTextElement[0].AppendChild(toastXml.CreateTextNode("eg"));
                //toastTextElement (toastTextElement[0] as XmlElement).InnerText = message;
                IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
                ((XmlElement)toastNode).SetAttribute("duration", "long");
                ToastNotification toast = new ToastNotification(toastXml);
                ToastNotificationManager.CreateToastNotifier().Show(toast);
                break;

            case PushNotificationType.Raw:
                notificationContent = e.RawNotification.Content;
                break;
        }

        e.Cancel = true;
    }

我试着获取准确的推送消息,但做不到..请参阅附件中的SS以了解钙化情况。

为什么我的包名在头中,但没有图像?为什么不显示真正的消息,而不是新通知?有人能帮我解决这个问题吗?提前谢谢你。

EN

回答 1

Stack Overflow用户

发布于 2017-04-11 20:08:10

请注意,对于Windows Phone 8.1及更高版本的Pushwoosh SDK集成流程与您之前遵循的流程不同:

http://docs.pushwoosh.com/docs/windows-8-sdk-integration

这是由于WP8.1使用WNS (Windows Push Notification ServiceS)进行推送消息传递,而不是WP8.0和更早版本上使用的MPNS。请注意,MPNS仍然可以向后兼容-这就是为什么你仍然会收到通知,但是它的内容应该是不同的,以显示在WP8.1设备上,特别是它应该是XML或原始内容编码在MIME的base64中的对象( language1:'content1',language2:'content2‘)或字符串的形式。

如果你通过Pushwoosh Remote API发送推送,你应该在"wns_content“中指定通知文本,而不仅仅是在”content“中:

"wns_content": { "en": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9ImF2YWlsYWJsZSIvPg==", "de": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48YmFkZ2UgdmFsdWU9Im5ld01lc3NhZ2UiLz4=" }

如果您通过Pushwoosh Dashboard发送通知,则应在单独的Windows选项卡中撰写邮件:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42934626

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档