http://ramosli.iteye.com/blog/1940843

前段时间,仔细研究了APNS的文档,把一些关键的地方记录了下来,弄懂这些对于理解APNS的规则,至关重要。

1. If APNs attempts to deliver a notification but the device is offline, the notification is stored for a limited period of time, and delivered to the device when it becomes available.

假如用户手机不在线,可能没有信号或者关机吧,APNs会存储转发,等用户在线时再发送

2.Only one recent notification for a particular application is stored. If multiple notifications are sent while the device is offline, each new notification causes the prior notification to be discarded. This behavior of keeping only the newest notification
is referred to as coalescing notifications.

如果用户不在线,通知会合并,只会保留最新的一条。假如你给用户发了两条通知,但用户反馈说,只收到了一条,那么很可能是用户当时不在线,APNs的合并策略生效,只保留了最近一条

3.If the device remains offline for a long time, any notifications that were being stored for it are discarded

4.The maximum size allowed for a notification payload is 256 bytes; Apple Push Notification Service refuses any notification that exceeds this limit.

这个很重要,payload,就是最后生成的那段Json,不得超过256字节。如果超过了,建议去掉一些不需要的参数,把alert,就是提示信息的字数减少

5.don’t repeatedly open and close connections. APNs treats rapid connection and disconnection as a denial-of-service attack.

6.If you send a notification that is accepted by APNs, nothing is returned.

发送成功的木有返回,只有发送失败的才会返回

7.If you send a notification that is malformed or otherwise unintelligible, APNs returns an error-response packet and closes the connection. Any notifications that you sent after the malformed notification using the same connection are discarded, and must be
resent.

这条非常重要,如果有error-response,那么这条之后的通知都需要重发。有很多开源的库,在发苹果通知时都没有检测error-response,如果你不小心用了,那么用户很可能反馈“怎么没有通知啊”

8.The notification identifier in the error response indicates the last notification that was successfully sent(实际情况不是,实际上返回的是出错的那条通知的ID). Any notifications you sent after it have been discarded and must be resent.When you receive this status code, stop using
this connection and open a new connection.

这是对上一条的补充,如果出错了,需要关闭当前的连接,并且重新连接再发。error-response中返回的通知ID,可以帮助我们找出哪条出错了,这样就能知道哪些需要重发了

9.When a push notification cannot be delivered because the intended app does not exist on the device, the feedback service adds that device’s token to its list.

APNS的feedback service会返回那些已经卸载的设备的token--device_token。存储这些token,下次就不用再给他们发了,可以节省点资源。需要注意的是:feedback的接口读取一次,APNS就会清空它的列表,下次再读取时,返回的就是这两次读取之间这段时间新产生的device_token。

只有把这些搞清楚,才方便我们理解苹果推送的规则,知道自己推送上的一些不足之处。搞懂这些规则后,我自己封装了个Java的类库,已经开源并放到Github上了,下一篇文章奉上详情。

苹果通知推送服务(APNS)一些关键特性摘要的更多相关文章

  1. 苹果通知推送服务(APNS)关键特性摘要

    1. If APNs attempts to deliver a notification but the device is offline, the notification is stored ...

  2. ZPush--基于netty4实现的苹果通知推送服务(APNs)Javaclient

    简单说下实现苹果通知推送服务(APNs)client的一些要注意的地方: 使用长连接: sanboxserver是无用的,调试时直接用"gateway.push.apple.com" ...

  3. 手把手教你配置苹果APNS推送服务|钿畑的博客 | 钿畑的博客

    http://www.360doc.com/content/15/0118/17/1073512_441822850.shtml# 钿畑的文章索引 1. 什么是推送通知 2. 什么是APNS? 3. ...

  4. IOS学习笔记—苹果推送机制APNs

    转自:唐韧_Ryan http://blog.csdn.net/ryantang03/article/details/8482259 推送是解决轮询所造成的流量消耗和 电量消耗的一个比较好的解决方案, ...

  5. 基于APNs最新HTTP/2接口实现iOS的高性能消息推送(服务端篇)

    1.前言 本文要分享的消息推送指的是当iOS端APP被关闭或者处于后台时,还能收到消息/信息/指令的能力. 这种在APP处于后台或关闭情况下的消息推送能力,通常在以下场景下非常有用: 1)IM即时通讯 ...

  6. 消息推送之APNS

    利用APNS进行消息推送 原理 APNS 是Apple Push Notification Service(Apple Push服务器)的缩写,是苹果的服务器. APNS推送可以分为三个阶段: 第一阶 ...

  7. MQTT协议及推送服务(二)

    MQTT简介 MQTT全称叫做Message Queuing Telemetry Transport,意为消息队列遥测传输,是IBM开发的一个即时通讯协议.由于其维护一个长连接以轻量级低消耗著称,所以 ...

  8. Android推送服务——百度云推送

    一.推送服务简介 消息推送,顾名思义,是由一方主动发起,而另一方与发起方以某一种方式建立连接并接收消息.在Android开发中,这里的发起方我们把它叫做推送服务器(Push Server),接收方叫做 ...

  9. .NET向APNS苹果消息推送通知

    一.Apns简介: Apns是苹果推送通知服务. 二.原理: APNs会对用户进行物理连接认证,和设备令牌认证(简言之就是苹果的服务器检查设备里的证书以确定其为苹果设备):然后,将服务器的信息接收并且 ...

随机推荐

  1. SharePoint 2010 -- .Net托管客户端模型简单示例

    .Net托管客户端模型,是SharePoint2010推出的三种客户端模型".NET托管"."ECMAScript"."Sliverlight&quo ...

  2. ELF 动态链接 so的动态符号表(.dynsym)

    静态链接中有一个专门的段叫符号表 -- ".symtab"(Symbol Table), 里面保存了所有关于该目标文件的符号的定义和引用. 动态链接中同样有一个段叫 动态符号表 - ...

  3. sql语句——根据身份证号判断男女

    根据身份证判断男女的规则:二代身份证为18位,判断倒数第二位,第二位若为奇数,性别为男:偶数则为女 一代身份证为15为,判断倒数第一位,规则同上. update 表名 set 表名.字段名= case ...

  4. 使用oracle sqldr命令导入文件后出现中文乱码问题

    1:导入命令 sqlldr userid=$DB_USER/$DB_PASS@@DB_SERVICE control=text.ctl errors=10000000  说明:username/pas ...

  5. IT轮子系列(一)——DropDownList 的绑定,你秒懂了吗

    前言 最近猛然惊觉(说是猛然,是因为自己工作那么多年,居然不自知.不反省),在开发中,自己碰到一些常用的功能代码块,还是习惯性的baidu,然后copy....这样的操作,不知自己重复了多少遍.现在回 ...

  6. 通过jQuery源码学习javascript(三)

    承接上两篇继续写下去.我尽量把我明白的地方给大家说清楚.有些大家的提问我也有点搞不明白,如果有人能解答,再好不过了 疑问  第一篇中有位博友提出了以下的问题,我也不太明白,如果有明白的,能否告知一.二 ...

  7. MySQL/MariaDB中的事务和事务隔离级别

    本文目录:1.事务特性2.事务分类 2.1 扁平事务 2.2 带保存点的扁平事务 2.3 链式事务 2.4 嵌套事务 2.5 分布式事务3.事务控制语句4.显式事务的次数统计5.一致性非锁定读(快照查 ...

  8. webService(一)开篇

    Webservice技术在web开发中算是一个比较常见技术.这个对于大多数的web开发者,别管是Java程序员还是.NET程序员应该都不是很陌生.今天我就和大家一起来学习一下webservice的基本 ...

  9. HashMap原理浅析

    HashMap概述 HashMap是基于哈希表和Map实现来的,它提供所有可选的映射方式,可以允许使用null键,除了不同步和允许使用null键之外,HashMap和HashTable基本上相同.因此 ...

  10. maven包加载

    1) IDEA包加载pom.xml配置 <build>    <sourceDirectory>src/main/java</sourceDirectory>    ...