美文网首页
推送获取设备的token

推送获取设备的token

作者: 菠萝吹雪xs | 来源:发表于2021-06-27 00:15 被阅读0次
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    if (![deviceToken isKindOfClass:[NSData class]]) {
         //记录获取token失败的描述
         return;
    }
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 13) {
        const unsigned *tokenBytes = (const unsigned *)[deviceToken bytes];
        NSString *strToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",
                                     ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
                                     ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
                                     ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];             
        
    }else{
        NSMutableString * devices_token = [NSMutableString stringWithFormat:@"%@",deviceToken];
        NSString *fileString = [devices_token copy];
      
    }
}

相关文章

网友评论

      本文标题:推送获取设备的token

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