美文网首页iOS
ios13 deviceToken

ios13 deviceToken

作者: 白色天空729 | 来源:发表于2019-07-25 14:44 被阅读0次
- (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

    本文链接:https://www.haomeiwen.com/subject/bhjhrctx.html