Solution

  1.  (NSString *)convertTokenToDeviceID:(NSData *)token
  2. {
  3.  NSMutableString *deviceID = [NSMutableString string];
  4.  // iterate through the bytes and convert to
  5.  hexunsigned char *ptr = (unsigned char *)[token bytes];
  6.  
  7.  for (NSInteger i=0; i < 32; ++i) {
  8.   [deviceID appendString:[NSString stringWithFormat:@"%02x", ptr[i]]];
  9.  }
  10.     return deviceID;
  11. }