2

I'm working on iOS MDM. During enrollment i got deviceToken, PushMagic and unlockToken. Plan to use javapns. It expect 64 hex value.

This is my original Device Token format. It is 32 byte binary value and base64 encoded.

54CC9f18PLXag/RgOCtc30o7lC3beG6NruUSE0/vCC0=

Do i need to convert the above format to send notification to APNs via javapns. If so how to convert encoded device token to 64 char hexadecimal.

Any help will be appreciated.

Thanks in Advance.

Regards, Vinothkumar.R

vinorathna
  • 21
  • 4

3 Answers3

2

Java, you try:

String token = "j9KAZ7nka3wwAfjCpONXrpAzxRP1vPMBl/x5CTCfKYI=";
byte[] bytes = Base64.decodeBase64(token.getBytes());
System.out.println("DeviceToken: " + Hex.encodeHexString(bytes));
Mr Phuc 87
  • 184
  • 2
  • 7
2

C# answer:

byte[] deviceToken = Convert.FromBase64String( "54CC9f18PLXag/RgOCtc30o7lC3beG6NruUSE0/vCC0=" );

then send the deviceToken binar byte[] to apple after the big endian length.

Seth
  • 51
  • 3
0

In NodeJs use

    var originalDeviceToken = '54CC9f18PLXag/RgOCtc30o7lC3beG6NruUSE0/vCC0=';
    var b = new Buffer(originalDeviceToken, 'base64')
    var hexToken = b.toString('hex');
San
  • 427
  • 3
  • 12