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

被折叠的 条评论
为什么被折叠?



