APNS(1)Apple Push Notification Service

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

猜你喜欢

转载自sillycat.iteye.com/blog/1769158
今日推荐