|
/

iOS日志无法打印出上传给友盟的deviceToken

Vv*
发布于 5 年前
220
消息推送 U-Push
SDK集成与升级

iOS日志无法打印出上传给友盟的deviceToken

2个回答
 
5 年前

iOS 13 之前和之后打印方式不一样

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

if (@available(iOS 13.0, *)) {
if (![deviceToken isKindOfClass:[NSData class]]) return;
const unsigned *tokenBytes = (const unsigned *)[deviceToken bytes];
NSString *token = [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(@"推送的Token:%@", token);
}else{
NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];

NSLog(@"推送的Token:%@", token);
}
}


Loading ...
登录社区,分享你的经验