|
The iPhone Wiki is no longer updated. Visit this article on The Apple Wiki for current information. |
Difference between revisions of "Apple Push Service Protocol"
(apnspack was added in iOS10) |
(Add Protocols category) |
||
| Line 100: | Line 100: | ||
==References== |
==References== |
||
*[https://github.com/meeee/pushproxy/blob/master/doc/apple-push-protocol-ios5-lion.md Source of this info] |
*[https://github.com/meeee/pushproxy/blob/master/doc/apple-push-protocol-ios5-lion.md Source of this info] |
||
| + | |||
| + | [[Category:Protocols]] |
||
Revision as of 21:40, 14 June 2021
iOS devices connect to Apple's push servers via port 5223. The protocol is proprietary and has nothing to do with XMPP (which uses the same port to establish SSL-encrypted client connections). The Push service protocol also uses SSL encryption.
As of iOS5, Apple uses a new push protocol. The same protocol is used on the Mac too. With iOS4, the protocol used message types 00 to 06, while the new protocol uses message types 07 to 0f and all fields have a type-length-value encoding.
While every iOS version after that continued adding new message and field types, since iOS 10 there is another new push protocol known as "apnspack", which uses the same message and field types but encodes them in a completely different binary format. The client negotiates use of this new protocol with the protocol name "apns-pack-v1" in ALPN. The apnspack format is not yet documented in this page.
Contents
Message Structure
The format of the non-packed APNS protocol is as follows:
- 1 byte message type
- 4 byte payload length
- fields, all with
- 1 byte type
- 2 byte length
- value
Example:
07message type (Connect)00 00 00 2739 byte payload length011st field00 2032 byte length8a 73 82 00 82 ac 91 32 88 b6 aa ef 90 91 65 ce 8a 73 82 00 82 ac 91 32 88 b6 aa ef 90 91 65 cevalue 1 (32-byte push token)
022nd field00 011 byte length01value
Messages
07 Connect
- Direction: device to server
- message type:
07 - fields:
0132-byte push token021 byte unknown (value01)
08 Connect Response
- Direction: server to device
- message type:
08 - fields:
01status (00ok,02some error)04unknown (value10 00)05unknown (value00 02)0332-byte push token (optional), sent after05field
09 Push Topics
- Direction: device to server
- message type:
09 - fields:
0220-byte ID for enabled topic (like topic for push-enabled app or a specific iCloud service like Find My iPhone)0320-byte ID for disabled topic
0A Push Notification
- Direction: server to device (for iMessage and possibly others too, also the other way round)
- message type:
0a - fields:
01recipient push token02topic03notification payload04response token05expiry (32-bit UNIX timestamp)06timestamp (64-bit UNIX timestamp in nanoseconds)07unknown (00)
0B Push Notification Response
- Direction: server to device (for iMessage and possibly others too, also the other way round)
- message type:
0b - fields:
04response token08status (00ok,02error)
0C Keep-Alive
- Direction: device to server
- message type:
0c - fields:
01connection method ("WiFi" or GSM MNC like "31038" for AT&T)02iOS version, e.g. "5.0"03iOS build number04device model, e.g. "iPhone2,1"05unknown (values like10,15or20)
0D Keep-Alive Confirmation
- Direction: server to device
- message type:
0d - no fields
0E No Storage
- Direction: server to device
- message type:
0e - fields:
0332-byte push token
0F Flush
- Direction: both
- message type:
0f - fields:
- 2-byte integer indicating length of padding
- padding: NULL-bytes, typical lengths are 64, 128, 256, 512