APNS(1)Apple Push Notification Service

本文详细介绍了APNS(Apple Push Notification Service)的工作原理,包括通知的传输路径、生成与验证过程,以及最大负载限制和通知送达机制。通过解析JSON格式的payload,了解了如何在iOS应用中注册接收推送通知。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

APNS(1)Apple Push Notification Service
APNS is Apple Push Notification Service.

A Push Notification and Its Path
Apple Push Notification service transports and routes a notification from a given provider to a given device. A notification is a short message consisting of two major pieces of data: the device token and the payload.

A device token is analogous to a phone number.

The payload is a JSON-defined property.

A push notification from a provider to a client application.
Provider ---notification------> APNS -------notification-----> IPhone ---notification---> ClientApp

Service-to-Device Connection Trust

Device APNS
TLS initiation ----->
<--------- Server certificate
Validate server certificate
Device certificate ------>
Validate device certificate
<----------TLS established

Provider-to-Service Connection Trust

Provider APNS
TLS initiation----------->
<----------------Server Certificate
Validate server certificate
Provider certificate ------>
Validate provider certificate
<----------------TLS established

Token Generation and Dispersal
An iOS-based application must register to receive push notifications. It does this right after it is installed on a device.

Provider Device APNS
-----Connect(Token--->
Generate token package
Generate device ID from device certificate
Encrypt token with token key
<--------Token ------------
<-----Token-----

This token will be used every time when we connect with APNs.

Token Trust(Notification)

Provider APNS Device
<----------Connect(Token…)--------
Encrypt token and
validate
with device certificate
-------------Response(OK)------------>
-------Token, Payload----->
Decrypt token with token key
------------- Payload --------------------->

The Notification Payload
The maximum size allowed for a notification payload is 256 bytes. And delivery of notifications is "best effort" and is not guaranted.

If the target application isn't running when the notification arrives, the alert message, sound, or badge value is played or shown.

Example of JSON Payloads
{
"aps" : {
"alert" : "You got your emails.",
"badge" : 9,
"sound" : "bingbong.aiff"
},
"acme1" : "bar",
"acme2" : 42
}


References:
http://code.google.com/p/javapns/
http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html

http://mobile.51cto.com/iphone-284849.htm
http://www.oschina.net/ios/293/ios-msg?type=3&sort=time

http://my.oschina.net/u/557242/blog/88751

http://www.cnblogs.com/hubj/archive/2012/06/14/2549816.html

https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值