差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 后一修订版 两侧同时换到之后的修订记录 | ||
im:ios:apns:deploy [2019/09/29 04:27] huanxinfudh [客户端如何申请DeviceToken] |
im:ios:apns:deploy [2019/11/22 04:27] huanxinfudh [客户端如何申请DeviceToken] |
||
---|---|---|---|
行 149: | 行 149: | ||
2、 将得到的deviceToken传到SDK | 2、 将得到的deviceToken传到SDK | ||
+ | ''如果是iOS13及以上的系统,请将SDK更新到v3.6.2及以上版本'' | ||
<code> | <code> | ||
- | iOS 13之前: | ||
// 将得到的deviceToken传给SDK | // 将得到的deviceToken传给SDK | ||
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken | - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken | ||
行 156: | 行 156: | ||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | ||
[[EMClient sharedClient] bindDeviceToken:deviceToken]; | [[EMClient sharedClient] bindDeviceToken:deviceToken]; | ||
- | }); | ||
- | } | ||
- | |||
- | iOS 13: | ||
- | // 将得到的deviceToken传给SDK | ||
- | - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken | ||
- | { | ||
- | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | ||
- | const unsigned *tokenBytes = [deviceToken bytes]; | ||
- | NSString *hexToken = [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])]; | ||
- | [[EMClient sharedClient] bindDeviceToken:token]; | ||
}); | }); | ||
} | } |