如何获得 Microsoft Push Notification Service(MPNS)的最佳体验
有很多同学抱怨MPNS的各种问题,其中包括服务超时、返回各种错误代码不知如何处理等等。。今天我用一点时间来为大家介绍下如何处理和操作咱们的MPNS。
首先为大家明确一个问题,Microsoft Push Notification Service (MPNS) 是执行的异步推送。今天将介绍如何使用高效的服务将我们的推送信息发送至云端最终发送到 Windows Phone 手机。
第一 如何设置发送超时
对于超时时间我建议大家设置为 15秒。例如:你使用的 ASP.NET 进行数据推送时,建立 WebRequest 对象设置超时时间
HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
request.Timeout = 15000;
第二 处理推送通道的更新
当你的客户端程序发现推送通道更新后,应用一定要将最新的推送通道 URL 更新到你的服务器端。要保证您的服务器端的推送通道是最新的。建议你可以使用 device ID 与推送通道进行匹配,如果发现推送通道的URL更新就立刻进行推送通道更新,服务器通过device ID进行判断是,新用户注册还是已有用户的推送通道更新。
Windows Phone 的官方资料中提供了如何建立一个接受推送消息的应用代码示例,其中包括了如何处理,推送通道更新事件。您可以参考 如何发送和接收 Windows Phone 的磁贴通知 了解如何使用PushChannel_ChannelUriUpdated方法。(另:推送通道长度也许会超过 1024 characters)
第三 使用已验证的 Web 服务以发送 Windows Phone 的推送通知
使用MPNS认证端,如果你的推送服务针对一台WindowsPhone设备24小时内推送消息数量超过500条,或者您想更安全的推送消息。另使用没有MPNS验证的终端进行推送,每日的推送限额是500条/每个device。
如何设置 MPNS验证的终端。
设置已验证的 Web 服务以发送 Windows Phone 的推送通知
No-quota push notifications using a root Certificate Authority
另外,如果你的推送服务超过每天500条的推送对每台设备,有一点您就需要额外的考虑用户的手机电量是使用情况了。
第四 根据MPNS返回的代码进行处理
通常移动设备的网络都会变化的,了解 Windows Phone 网络连接的变换状态判断规则:设备状态的过度流程
你将推送服务发送至MPNS,随后MPNS会将设备的信息返回,你需要观察设备状态(Windows Phone 的推送通知服务响应代码),在进行处理我推荐一些做法如下:
Response code | Notification status | Device connection status | Subscription status | Recommendations |
200 OK | QueueFull | Connect | Active | 建议从新发送通知,但是可以设置一个重发时间间隔,如果还收到同样错误代码尝试延长重试时间:4 – 8 – 16 分钟以此类推到32分钟。 |
200 OK | QueueFull | Temp Disconnected | Active | 建议从新发送通知,但是可以设置一个重发时间间隔,如果还收到同样错误代码尝试延长重试时间:2 – 4 – 8 分钟以此类推到 24 小时。 |
404 Not Found | Dropped | * Any Connection Status | Expired | 不需要再尝试发送消息了,因为这个推送通道已经不存在了。 |
412 Precondition Failed |
Dropped | Disconnected | N/A | 建议每小时尝试一次从新发送,但是如果超过24小时还是返回相同错误,就停止推送。 |
503 | N/A | N/A | N/A | 建议从新发送通知,但是可以设置一个重发时间间隔,如果还收到同样错误代码尝试延长重试时间:5 – 10 – 20 – 40 秒以此类推到30分钟。 |
更多资源请参考:
如何获得 Microsoft Push Notification Service(MPNS)的最佳体验的更多相关文章
- Microsoft Push Notification Service(MPNS)的最佳体验
如何获得 Microsoft Push Notification Service(MPNS)的最佳体验 有很多同学抱怨MPNS的各种问题,其中包括服务超时.返回各种错误代码不知如何处理等等..今天我用 ...
- Provider Communication with Apple Push Notification Service
This chapter describes the interfaces that providers use for communication with Apple Push Notificat ...
- (转)在SAE使用Apple Push Notification Service服务开发iOS应用, 实现消息推送
在SAE使用Apple Push Notification Service服务开发iOS应用, 实现消息推送 From: http://saeapns.sinaapp.com/doc.html 1,在 ...
- 陌陌架构分享 – Apple Push Notification Service
http://blog.latermoon.com/?p=878 先描述下基本概念,标准的iPhone应用是没有后台运行的,要实现实时推送消息到手机,需要借助Apple提供的APNS服务. iPhon ...
- Missing Push Notification Entitlement 问题
最近打包上传是遇到一个问题: 描述: Missing Push Notification Entitlement - Your app includes an API for Apple's Push ...
- iOS上简单推送通知(Push Notification)的实现
iOS上简单推送通知(Push Notification)的实现 根据这篇很好的教程(http://www.raywenderlich.com/3443/apple-push-notification ...
- apple 官方文档 Push Notification Programming
iOS Developer LibraryDeveloper Search Local and Push Notification Programming Guide PDF Table of Con ...
- (转)How to build an Apple Push Notification provider server (tutorial)
转自:https://blog.serverdensity.com/how-to-build-an-apple-push-notification-provider-server-tutorial/ ...
- (转)Apple Push Notification Services in iOS 6 Tutorial: Part 2/2
转自:http://www.raywenderlich.com/32963/apple-push-notification-services-in-ios-6-tutorial-part-2 Upda ...
随机推荐
- SpringMVC源码总结(一)HandlerMapping和HandlerAdapter入门
SpringMVC在使用过程中,大多是使用注解,对它的实现接口之类的关系理解变得模糊, 通过对XML配置的理解,可以理清各个类的关系,譬如控制器类要实现Controller接口. 接触SpringMV ...
- jQuery实现锚点滑动定位
go=function(index){ var top = $('#caseNewGuide' + index).offset().top; $('html, body').animate({ scr ...
- 解决Lightmap在PC上与ios和Android上表现不同的问题
Lightmap在PC上与android和ios的区别以及解决方法 1. 问题描述 相信很多人碰到过Lightmap的一些问题: 烘培好Lightmap之后,在PC上看起来相当给力,而打包成ios或 ...
- Message: u'$ is not defined' ; Stacktrace
status.html <html> <head> <meta http-equiv="content-type" content="tex ...
- discuz模板引擎语法
论坛的首页模板:forum/discuz.htm 版块的内容模板:forum/forumdisplay.htm 主题的查看模板:forum/viewthread.htm 帖子的内容模板:forum/p ...
- MySql 几个小技巧
分页查看: 在 mysql 环境下,执行命令: pager more,之后的结果分屏了. 简明扼要地查看表结构: describe table_name
- Netty 源码(一)服务端启动
Netty 源码(一)服务端启动 Netty 系列目录(https://www.cnblogs.com/binarylei/p/10117436.html) ServerBootstap 创建时序图如 ...
- centos7 nginx 加入开机启动
设置nginx开机启动 vi /etc/rc.d/init.d/nginx #编辑启动文件添加下面内容 ############################################### ...
- c#递归实现螺旋数组
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...
- 1、wei-d-s嵌入式与PC区别,LED等的点亮以及调用C函数
tiny6410之点亮Led灯: .global _start _start: ldr r0,0x70000000 //目的是把外设基地址告诉cpu orr r0,r0,#0x13 mcr p15,0 ...