推送获取设备的token
2021-06-27 本文已影响0人
菠萝吹雪xs
- (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];
}
}