MDM TokenUpdate Token
I'm receiving the TokenUpdate from the device, but it looks like:
| <key>Token</key> | |
| <data> | |
| tXYV0+IN3+/qUaJa3P1OUclO4AJQTOGb6SjjAVTyF40= | |
| </data> |
How do I decode the Token data so I can use it for an APNS notification?
I'm receiving the TokenUpdate from the device, but it looks like:
| <key>Token</key> | |
| <data> | |
| tXYV0+IN3+/qUaJa3P1OUclO4AJQTOGb6SjjAVTyF40= | |
| </data> |
How do I decode the Token data so I can use it for an APNS notification?
When I undecode as base64 the token comes out all garbled. I have an APNS token from the same device that works properly. The MDM protocol reference doesn't say how the TokenUpdate token is supposed to look or be used.
I have the same issue when I receive the device token from the tokenupdate call. Did you solve this?
Hi there,
I have been working on this issues for a while as we're developing an MDM service at the moment. As we all know, the Apple documentation on MDM is anything but helpful as much as we would like to.
So what happens here is that you're receiving the deviceToken as a Base64 string. In order to use it, you just have to Base64 decode it and send the resulting result as is. If you try to "print" the resulting result of the decoding, you will see that instead of looking like the regular "XXXX-XXXX...." that is commonly known, it looks like garbage. That is because it is actually binary data.
Sending your MDM commands with it decoded like that should work without a problem. However, I found out that some libraries (if you're using one of the libraries out there to do the final send) do not accept the binary format. All you have to do then is to find a function in the language you're using to turn it into a HEX string.
In my case I am using PHP. So this is what it turns out to be:
$token = bin2hex(base64_decode($deviceToken));
I hope this helps.
Regards.
MDM TokenUpdate Token