更新时间:2023-01-20 13:10:33
只是一个小尖,为了您收到的令牌转换为适合与javapns登记的格式,这code将这样的伎俩:
Just a little tip, in order to convert your received token into a format suitable for registration with javapns, this code will do the trick:
- (NSString *)convertTokenToDeviceID:(NSData *)token {
NSMutableString *deviceID = [NSMutableString string];
// iterate through the bytes and convert to hex
unsigned char *ptr = (unsigned char *)[token bytes];
for (NSInteger i=0; i < 32; ++i) {
[deviceID appendString:[NSString stringWithFormat:@"%02x", ptr[i]]];
}
return deviceID;
}