ios iPhone 设备令牌的大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12452448/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 20:11:21  来源:igfitidea点击:

Size of iPhone device token

iosapple-push-notifications

提问by user462455

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

APNs(Apple Push Notification)生成的设备令牌的大小是多少。我正在尝试将服务器端的设备令牌存储在 mysql 数据库中,并想知道生成的设备令牌的最大大小

回答by Philip Whitehouse

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

你被告知,但它目前是 32 个字节。Apple 表示令牌长度是可变的,不要对其进行硬编码

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

当您收到通知时,它有一个标头,当前大小为 35 个字节。安排如下:

  • Byte 1:Command
  • Byte 2-3:Token length
  • Bytes 4-35:Token
  • 字节 1:命令
  • 字节 2-3:令牌长度
  • 字节 4-35:令牌

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

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

回答by Samo

Apple Push Notification Service Programming guidevery clearly says:

Apple Push Notification Service Programming guide非常清楚的说:

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

“重要提示:APN 设备令牌的长度可变。不要对其大小进行硬编码。”

回答by Cameron Bielstein

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

根据 Apple 的 iOS Developer Library,正如 Philip 所说,它是 32 字节。

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

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

回答by James Hall

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.

据报道,iOS8 中的限制为 2k。不过半GCM的4K大小的,但我相信大部分人都会有改变自己的表来处理新iOS8上的令牌限制。