推送通知的 iOS 设备令牌示例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30821090/
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-31 06:24:39  来源:igfitidea点击:

iOS Device Token example for Push Notifications

iosswiftpush-notification

提问by Arthur

I need to pass through server auth method, which needs deviceToken for registration. But I have only simulators, and can't take tokens from them, and I want to send to server false token (like 000 000 000) But I don't know how many digits are there in device token. Can anyone help me out with a sample device token?

我需要通过 server auth 方法,该方法需要 deviceToken 进行注册。但是我只有模拟器,不能从它们那里获取令牌,我想向服务器发送错误令牌(如 000 000 000)但我不知道设备令牌中有多少位数字。任何人都可以用示例设备令牌帮助我吗?

回答by iYoung

Device token is of 32 Bytes. Sample device token is provided for your reference from raywenderlich

设备令牌为 32 字节。raywenderlich提供了示例设备令牌供您参考

740f4707 bebcf74f 9b7c25d4 8e335894 5f6aa01d a5ddb387 462c7eaf 61bb78ad

回答by fpg1503

Apple Local and Remote Notification Programming Guide clearly states:

Apple 本地和远程通知编程指南 明确指出:

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

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

The may currently have 32 bytes but hardcoding that will make your app break in the future!

目前可能有 32 个字节,但硬编码将使您的应用程序在未来崩溃!

回答by mgyky

It is 32 bytes. Written in hexadecimal they will take 64 digits.

它是 32 个字节。以十六进制编写,它们将占用 64 位数字。

You can check this page for more detail :

您可以查看此页面以获取更多详细信息:

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html