Size of iPhone device token
Asked Answered
A

4

21

What is the size of the device token generated by APNs (Apple Push Notification). I am trying to store device tokens on the server side in a mysql database, and would like to know maximum size of device tokens generated

Abound answered 17/9, 2012 at 2:19 Comment(2)
it is 64 char in lengthBereft
it is not 64 char in lenght anymore, it changes, some of them 64 some of them 108 etc.Ician
K
21

You get told but it's currently 32 bytes. Apple says the token length is variable and to not hard code it

When you get a notification it has a header, currently 35 bytes in size. This is arranged as follows:

  • Byte 1: Command
  • Byte 2-3: Token length
  • Bytes 4-35: Token

Source: http://mark.aufflick.com/files/view/talks/apns.pdf

Ketone answered 17/9, 2012 at 2:28 Comment(3)
you have said its totaly 32 bytes ...But you are mentioning Bytes 4-35...can you plz explain that ?Midwinter
@NagaR I've just expanded the content a bit to explain where the numbering comes from. The number is the index in the header. So byte 1 of the token occupies byte 4 in the header, byte 2 in the token occupies byte 5 in the header... byte 32 of the token occupies byte 35 in the header.Ketone
Apple says the token length is variable and to not hard code it: developer.apple.com/library/ios/documentation/…Agape
A
19

Apple Push Notification Service Programming guide very clearly says:

"Important: APNs device tokens are of variable length. Do not hardcode their size."

Addlepated answered 2/6, 2016 at 23:17 Comment(2)
I wish this question would be revisited. This is (as of now) the correct answer.Agape
updated documentation: developer.apple.com/library/archive/documentation/…Hautboy
L
4

According to Apple's iOS Developer Library, it's 32 bytes, as Philip said.

Here's a link to their page on "Local and Push Notification Programming," which may include other helpful information on the subject.

https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/Introduction.html

Leu answered 17/9, 2012 at 2:36 Comment(3)
The link is brokenZoie
@Zoie the link is fixedMoray
@Moray the link is broken againBanta
E
-7

The limit in iOS8 is reported to be 2k. Still half of the size of GCM's 4k, but I suspect most people will have to alter their tables to handle the new iOS8 token limit.

Explicate answered 11/6, 2014 at 17:3 Comment(4)
he didn't ask about the size of the push payload, but the token itself.Westberry
GCM token can (technically) be up to 4k long as well. Practically it should be within 255 though.Geniality
I agree with James, GCM's token length can be up to 4K and the payload itself can be up to 4K.Famous
The question was about token size, not about payload size.Borodin

© 2022 - 2024 — McMap. All rights reserved.