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

2023-05-16

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上了,下一篇文章奉上详情。




本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

  • 2014年度总结——软件产品化的简要理解

    2014年度总结 软件产品化的简要理解 2014年转瞬即逝 xff0c 真是让人感慨 xff0c 岁月不是一天天在逝去 xff0c 而是一年年 xff1b 总结一年的工作非常有意义 xff0c 觉得今年最大的变化就是从定制软件到产品化的过度
  • R语言中mean函数

    mean函数是求算术平均值 用法 xff1a mean x trim 61 0 na rm 61 FALSE x是数值型 逻辑向量 trim表示截尾平均数 xff0c 0 0 5之间的数值 xff0c 如 xff1a 0 10表示丢弃最大1
  • 使用Spring @DependsOn控制bean加载顺序

    使用Spring 64 DependsOn控制bean加载顺序 spring容器载入bean顺序是不确定的 xff0c spring框架没有约定特定顺序逻辑规范 但spring保证如果A依赖B 如beanA中有 64 Autowired B
  • 使用R中merge()函数合并数据

    使用R中merge 函数合并数据 在R中可以使用merge 函数去合并数据框 xff0c 其强大之处在于在两个不同的数据框中标识共同的列或行 如何使用merge 获取数据集中交叉部分 merge 最简单的形式为获取两个不同数据框中交叉部分
  • 介绍java中Pair

    介绍java中Pair 在这篇文章中 xff0c 我们讨论了一个非常有用的编程概念 xff0c 配对 Pair 配对提供了一种方便方式来处理简单的键值关联 xff0c 当我们想从方法返回两个值时特别有用 在核心Java库中可以使用配对 Pa
  • python numpy 中linspace函数

    python numpy 中linspace函数 numpy提供linspace函数 有时也称为np linspace 是python中创建数值序列工具 与Numpy arange函数类似 xff0c 生成结构与Numpy 数组类似的均匀分
  • 把文件夹里的文本批量替换内容

    下面的例子 xff0c 把 tmp task文件夹里 xff0c 所有文本文件中的 10 10 10 10 替换为 20 20 20 20 sed i 34 s 10 10 10 10 20 20 20 20 g 34 96 grep rl
  • openssl生成RSA私钥

    openssl OpenSSL gt genrsa out app private key pem 2048 默认生成PKCS 1的私钥 xff0c 2048表示私钥的长度 xff0c 我们建议是2048位 xff0c 这样安全 xff0c
  • ubuntu Ad-Hoc组网通信

    目录 WIFI通信的多种组网方式 1 AP模式 2 Ad hoc模式 ubuntu18配置ad hoc模式 WIFI通信的多种组网方式 1 AP模式 最常用的模式 xff0c 需要一个节点 xff08 一般是路由器 xff09 作为AP x
  • github中误上传,文件夹中包含.git,导致没法上传里面文件的方法

    假设包含 gi的文件夹为vendor github com 360EntSecGroup Skylar excelize xff0c 则可以 xff1a span class token function git span span cla
  • bluehost虚拟主机的301重定向<原创>

    http www bluehost cn com bluehost domain redirects 出于SEO PR值传递 网址转换的目的 xff0c 在网站初建和网站迁移时我们都需要使用301重定向 xff0c 通常包括域名对域名 xf
  • 一个很全部的验证手机号码的函数

    验证手机号是否正确 64 author 曾健生 64 param unknown type mobile public function validateMobile mobile 手机号码 移动 xff1a 134 0 8 135 136
  • .htaccess:正则表达式、重定向代码

    http codeyun com zonghe 235 html 位于行首时表示注释 F Forbidden xff08 禁止 xff09 命令服务器返回 403 Forbidden错误给用户浏览器 L Last rule xff08 最后
  • .htaccess技巧: URL重写(Rewrite)与重定向(Redirect)

    http lesca me archives htaccess rewrite html comment page 1 comment 16045 目录 Table of Contents 一 准备开始 xff1a mod rewrite

随机推荐

  • es实现mysql like的查询

    es中需要先安装中文分词插件ik 如果之前有这个索引 xff0c 需要先删除索引 DELETE lepeng 创建一个索引 PUT lepeng 指定索引的格式 ik max word 将文本做最细粒度的拆分 ik smart 会做最粗粒度
  • mysql错误:Error 1045: Access denied for user 的解决

    golang中 xff0c 在程序中配置的mysql地址是 xff1a 10 10 10 131 但是程序链接mysql时返回的错误是如下 xff1a Error 1045 Access denied for user 39 root 39
  • php代码解决跨域问题

    header 34 Access Control Allow Origin 34 header 34 Access Control Allow Methods OPTIONS GET POST DELETE PUT 34 header 34
  • 解决“Let‘s Encrypt“ 证书过期的错误消息

    https www cnblogs com tutuye p 11589546 html https manuals gfi com en kerio connect content server configuration ssl cer
  • 转:ubuntu22.04桌面版开启root用户登陆并开启root用户远程ssh连接

    https yunml blog csdn net article details 127145272
  • ROG配置ubuntu20.04.5双系统要点

    win11 43 ubuntu20 04 5 1 BIOS设置 开机长按F2进入bios设置 xff0c 修改advanced参数 xff1a boot gt 关闭fast bootsecurity gt 关闭secure boot设置VM
  • 《自己动手写Docker》书摘之一: Linux Namespace

    Linux Namespace 介绍 我们经常听到说Docker 是一个使用了Linux Namespace 和 Cgroups 的虚拟化工具 xff0c 但是什么是Linux Namespace 它在Docker内是怎么被使用的 xff0
  • app后端设计(1)--api(2014.01.31更新)

    1 Restful设计原则 Restful风格 xff1a RESTfu设计原则 它被Roy Felding提出 xff08 在他的 基于网络的软件架构 论文中第五章 xff09 而REST的核心原则是将你的API拆分为逻辑上的资源 这些资
  • [How To] Remove deleted records from Main Index in Sphinx

    http www sanisoft com blog 2013 06 28 remove deleted records in sphinx The problem You probably landed here searching fo
  • 左右值无限分类实现算法[转]

    http www jcwcn com archiver tid 227253 html 一 引言 产品分类 xff0c 多级的树状结构的论坛 xff0c 邮件列表等许多地方我们都会遇到这样的问题 xff1a 如何存储多级结构的数据 xff1
  • 给xmpphp添加了几个常用的方法

    给xmpphp添加给了以下的常用方法 xff1a registerNewUser 注册一个新用户 addRosterContact 发送添加好友的请求 accept friend request 接受好友请求 deleteRosterCon
  • app后端设计(2)--xmpp的使用(2014.01.14更新)

    在app中有时候是需要添加聊天服务 xff0c 在这里谈谈曾经开发聊天服务的经验 xff1a xff08 1 xff09 聊天服务端选的openfire xff0c 这是一个基于xmpp协议的聊天服务器 xff08 XMPP是一种基于XML
  • Nginx Location配置总结

    http blog sina com cn s blog 97688f8e0100zws5 html 语法规则 xff1a location 61 uri 61 开头表示精确匹配 开头表示uri以某个常规字符串开头 xff0c 理解为匹配
  • Nginx 下配置SSL证书的方法

    http www jb51 net article 24629 htm 默认 Nginx 是没有 ssl 模块的 xff0c 而我的 VPS 默认装的是 Nginx 0 7 63 xff0c 顺带把 Nginx 升级到 0 7 64 并且
  • 使用nginx搭建https服务器

    http www cnblogs com tintin1926 archive 2012 07 12 2587311 html 最近在研究nginx xff0c 整好遇到一个需求就是希望服务器与客户端之间传输内容是加密的 xff0c 防止中
  • Nginx与Lua

    http www cnblogs com xd502djj archive 2012 11 20 2779598 html 今天安装lua试试 xff0c 这个从开始装的 xff0c 发现一篇文字 xff0c 字数虽少 xff0c 但是却讲
  • MYSQL的空间查询

    http blog sina com cn s blog a48af8c001018q1p html 本文将向各位介绍如何使用MySql5 x中的空间数据库 xff0c 并展示一下它高效的性能 xff08 前提是正确使用 xff09 本文适
  • APM飞控使用动捕等外部定位

    本文初次写于2023 03 03 xff0c pixhawk飞控应该是刷写了ArduPilot 4 1以上的版本 机载计算机通过WIFI和vrpn ros client获取动捕系统 xff08 vicon或者nokov xff09 的无人机
  • APNS导致消息丢失和发送效率原因

    http blog csdn net tlq1988 article details 9612237 首先说明一下 xff0c 本文只是介绍一些容易被开发者忽视 xff0c 而导致性能低下问题 并不是介绍如何向苹果设备成功发送一条消息 xf
  • 苹果通知推送服务(APNS)一些关键特性摘要

    http ramosli iteye com blog 1940843 前段时间 xff0c 仔细研究了APNS的文档 xff0c 把一些关键的地方记录了下来 xff0c 弄懂这些对于理解APNS的规则 xff0c 至关重要 1 If AP