0
- (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
}
4

1 回答 1

0

我听不懂你在说什么。但是您使用NSData错误NSString

NSString *token=[[NSString alloc] initWithData:deviceToken encoding:NSUTF8StringEncoding];

NSData *deviceToken = [token dataUsingEncoding:NSUTF8StringEncoding];

使用上述两个函数进行转换NSStringNSData反之亦然。

于 2012-10-13T11:34:53.883 回答