iOS Device Token example for Push Notifications

2019-04-23 02:02发布

问题:

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?

回答1:

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

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


回答2:

Apple Local and Remote Notification Programming Guide clearly states:

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

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



回答3:

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

You can check this page for more detail :

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