ios13 deviceToken

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

    if (@available(iOS 13.0, *)) {
        NSMutableString *deviceTokenString = [NSMutableString string];
        const char *bytes = deviceToken.bytes;
        NSInteger count = deviceToken.length;
        for (int i = 0; i < count; i++) {
            [deviceTokenString appendFormat:@"%02x", bytes[i]&0x000000FF];
        }
    } else {
        NSString *deviceTokenStr =  [[[[deviceToken description]                                       
                                       stringByReplacingOccurrencesOfString:@"<" withString:@""]                                      
                                      stringByReplacingOccurrencesOfString:@">" withString:@""]                                     
                                     stringByReplacingOccurrencesOfString:@" " withString:@""];
    }
}

借鉴一个大佬:
https://www.jianshu.com/p/a0cc0f4e99c7

你可能感兴趣的:(ios13 deviceToken)