// 将deviceToken转换成字符串
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
// 方式1
NSMutableString *deviceTokenString1 = [NSMutableStringstring];
const char *bytes = deviceToken.bytes;
int iCount = deviceToken.length;
for (int i = 0; i < iCount; i++) {
[deviceTokenString1 appendFormat:@"%02x", bytes[i]&0x000000FF];
}
NSLog(@"方式1:%@", deviceTokenString1);
// 方式2
NSString *deviceTokenString2 = [[[[deviceTokendescription] stringByReplacingOccurrencesOfString:@"<"withString:@""]
stringByReplacingOccurrencesOfString:@">" withString:@""]
stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"方式2:%@", deviceTokenString2);
}