差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版 两侧同时换到之后的修订记录
im:ios:apns:deploy [2019/04/11 03:13]
jk [SDK的运行状态]
im:ios:apns:deploy [2019/09/29 04:22]
huanxinfudh [客户端如何申请DeviceToken]
行 150: 行 150:
  
 <​code>​ <​code>​
 +iOS 13之前:
 // 将得到的deviceToken传给SDK // 将得到的deviceToken传给SDK
 - (void)application:​(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:​(NSData *)deviceToken - (void)application:​(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:​(NSData *)deviceToken
行 155: 行 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 *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]),​
 +
 +        [[EMClient sharedClient] bindDeviceToken:​token];​
     });     });
 } }