Windows Phone 8 开发快速入门(八)



主要内容:推送通知

推送通知

推送通知为开发者提供了定期将信息传递给应用的功能,即使应用没有启动。图块可以为用户显示最关注的信息

推送通知数据流

Notifications service<--->MPNS(Microsoft hosted server)

Third-party service<-->Notificatins service

Third-party service4-->MPNS

服务器端发起的通信

推送通知的架构

三种类型的推送通知:Raw,Toastand Tile

Raw:通知消息的内容由程序定义,如果程序运行,则直接发送给应用

使用以下的HTTP head:

sendNotificationRequest.ContentTyp0e="text/xml";

sendNotificationRequest.Headers.Add("X-NotificationClass","<batchinginterval>");

String tileMessage="<?xml version=\"1.0\"encoding=/"utf-8"?>"+

"<root>"+

"<Value1>SomeUserValue<Value1>"+

"<Value2>SomeOtherUserValue<Value2>"+

"</root>";

 

Toast:特定的XML格式,如果程序正在运行,则直接将内容传递给程序,触发ShellToastNotificationReceived事件;如果程序没有运行,系统将显示toast的弹出通知,显示Toast消息内容

使用以下的HTTP head:

sendNotificationRequest.ContentTyp0e="text/xml";

sendNotificationRequest.Headers.Add("X-WindowsPhone-Target","toast");

sendNotificationRequest.Headers.Add("X-NotificationClass","<batchinginterval>");

String toastMessage="<?xml version=\"1.0\"encoding=\"utf-8\"?>"+

"<wp:Notificationxmlns:wp=\"WPNotification\">"+

"<wp:Toast>"+

"<wp:Text1>WEATHER ALERT </wp:Text1>"+

"<wp:Text2>Stormy</wp:Text2>"+

"<wp:Param>/page1.xaml?value1=1234<wp:Param>"+

"</wp:Toast>"+

"</wp:Notification>";

Tile:特定XML格式,不会传递给应用,如果应用图标被固定在开始屏幕,在系统将更新通知消息的内容

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值