APNS - Apple Push Notification Service

APNS - Apple Push Notification Service

当一个APP有新的数据到达时,Provider向APNS发送一个通知(Notification),然后APNS将这个通知推送给目标设备

APNS有一个默认的服务质量组件,可以提供存储和转发的能力。如果APNS尝试给一个离线的设备发送通知,那么APNS会先存储该通知一段时间,然后当设备可用时,再将通知推送给该设备。对于一个特定的APP,只有最近的一个通知会被存储。如果在设备离线期间,有多个通知被发送到给设备,那么没新到一个通知就会丢弃之前的那个通知。如果设备离线时间太长,存储的通知将都会被丢弃。

一个通知(Notification)由两部分组成:the device token和the payload。The device token可以使APNS定位安装APP的设备(device)。The payload,是json格式的通知内容。

Pushing a remote notification from a provider to a client app:

安全性

连接信任(connection trust)和token trust

连接信任,the Provider应该被认证;连接的设备也是一个合法的设备

a device token,是一个设备标志符,当设备第一次连接APNS时,由ANPS分配的。设备向Provier分享该设备标志符,因此每个通知里都会包含设备标志符。

UIDevice的属性identifierForVendor,是一个数字型的字符串唯一的标志一个设备到app’s vendor。

Service-to-Device Connection Trust

Provider-to-Service Connection Trust

Token Genetation and Dispersal

应用(Apps)必须注册接收远程通知。一般在应用安装到设备上后。设备系统受到注册来自APP的注册请求,然后连接ANPS,把这个请求转发给APNS。请求中包含设备的证书,APNS使用设备证书中包含的信息生成一个device token。device token包含这个设备的标志符。APNS使用一个token key加密加密这个device token,然后return it to the device:

设备向发送注册请求的APP以NSData的数据类型返回device token。然后这个APP必须发送这个device token给它的provier以二进制或者十六进制的格式。

Sharing the device token:

Token Trust(Notification)
设备系统从APNS获取了device token后,在设备系统每次连接到APNS时,必须向APNS提供这个device token。一个Provider经过APNS向一个设备发送通知时,也必须包含该设备的device token。APNS使用token key解密device token后,从中获取device ID,从而定位哪个device接收该通知。

注:
the topic is the bundle ID of the client app

The Notification Payload

在iOS 8及之后, a notification payload 被允许最大为2KB;在8之前和在OS X,最大的payload是256 bytes。

参考资源:
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值