zoukankan      html  css  js  c++  java
  • 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);
    }
    }

    一天一章
  • 相关阅读:
    Python 字符串和list的功能翻译
    python .strip()
    python 查看对象功能
    python 字典
    洛谷 P1144 最短路计数 Label:水
    心疼自己,再见
    初赛复习 //附复习资料
    51Nod 1079 中国剩余定理 Label:数论
    转载 乘法逆元
    51Nod 1136 欧拉函数 Label:数论
  • 原文地址:https://www.cnblogs.com/hangman/p/11732100.html
Copyright © 2011-2022 走看看