ios13推送DeviceToken
Posted huangyan1022
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ios13推送DeviceToken相关的知识,希望对你有一定的参考价值。
//获取DeviceToken成功
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
//Xcode11打的包,ios13获取Token有变化
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 13) {
if (![deviceToken isKindOfClass:[NSData class]]) {
//记录获取token失败的描述
return;
}
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])];
NSLog(@"deviceToken1:%@", strToken);
return;
} else {
NSString *token = [NSString
stringWithFormat:@"%@",deviceToken];
token = [token stringByReplacingOccurrencesOfString:@"<" withString:@""];
token = [token stringByReplacingOccurrencesOfString:@">" withString:@""];
token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"deviceToken2 is: %@", token);
}
}
以上是关于ios13推送DeviceToken的主要内容,如果未能解决你的问题,请参考以下文章
iOS13.6越狱有望/iOS13.6以及iOS12.4.8推送更新/苹果加入新人权Emoji表情