- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSLog(@"%@", [NSString stringWithFormat:@"%@", deviceToken]);
//display:
//<682e6887 ad7c7268 38861e90 6f4b9ba7 ced1299e abf3084b ca2ca75a 11111111>
NSString *token = @"<682e6887 ad7c7268 38861e90 6f4b9ba7 ced1299e abf3084b ca2ca75a 11111111>";
NSData *tokenData = [token dataUsingEncoding:NSASCIIStringEncoding];
NSLog(@"%@", [NSString stringWithFormat:@"%@", tokenData]);
//display:
//3c36383265363838372061643763373236382033383836316539302036663462396261372063656431323939652061626633303834622063613263613735612031313131313131313e
}
答案 0 :(得分:0)
我无法理解你在说什么。但您错误地使用了NSData
和NSString
。
NSString *token=[[NSString alloc] initWithData:deviceToken encoding:NSUTF8StringEncoding];
NSData *deviceToken = [token dataUsingEncoding:NSUTF8StringEncoding];
使用以上两个功能将NSString
转换为NSData
,反之亦然。