美文网首页
iOS | 集成极光推送遇到的坑

iOS | 集成极光推送遇到的坑

作者: Rickie_Lambert | 来源:发表于2018-06-12 15:11 被阅读1272次

---------------->Bug_001<----------------
iOS 10 新增了大量关于通知的新特性,详情参照极光官方的Blog。
iOS 10新增了Service Extension

错误日志如下:
Undefined symbols for architecture arm64:
"_dns_parse_resource_record", referenced from:
-[JPushExtensionSRVResolver processRecord:length:] in jpush-extension-ios-1.1.1.a(JPushExtensionSRVResolver.o)
"_dns_free_resource_record", referenced from:
-[JPushExtensionSRVResolver processRecord:length:] in jpush-extension-ios-1.1.1.a(JPushExtensionSRVResolver.o)

ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

bug001.png

解决办法就是: 添加相关的依赖库 libresolv.tbd 就可以了

bug003.png

---------------->Bug_002<----------------
极光错误提示:
| JIGUANG | W - [JIGUANGDeviceTokenController] Not get deviceToken yet. Maybe: your certificate not configured APNs? or current network is not so good so APNs registration failed? or there is no APNs register code? Please refer to JPush docs.

| JIGUANG | W - [JIGUANGDeviceTokenController] Not get deviceToken yet. After successful login, a custom message can be sent, but the APNs notification cannot. Until the deviceToken is obtained and reported successfully, the APNs notification can be used normally.

bug005.png

这样的错误提示,是因为在

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

这个方法里,没有执行极光推送的方法将deviceToken传给SDK

// 将得到的deviceToken传给SDK
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [[EMClient sharedClient] bindDeviceToken:deviceToken];
    });
    
    [JPUSHService registerDeviceToken:deviceToken];
}

但是我明明在 AppDelegate.m 里面实现了上面的方法,并写入了极光推送的注册DeviceToken方法,但是发现就是不走上面的方法,后来看到了下面这篇博客,原来有人跟我遇到了同样的问题,就是在使用环信IM的时候,同时也集成了极光推送,在使用环信IM的时候,它在AppDelegate的分类中重写了方法didRegisterForRemoteNotificationsWithDeviceToken: ,覆盖了我在AppDelegate中写的方法,所以导致我在方法里写的极光推送注册deviceToken的方法不执行。

错误记录的博客 Not get deviceToken yet. Maybe: your certificate not configured APNs?

http://www.cocoachina.com/bbs/read.php?tid=257513&page=e&#a

原来 环信IM 为AppDelegate 添加了一个 类目:AppDelegate+EaseMob.h,重写了

  • (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
    ,所以之前的app delete 里面写了
    [JPUSHService registerDeviceToken:deviceToken];
    没有调用,所以收不到推送。
    找了半天,才发现。

解决办法:就是将极光推送的deviceToken注册方法放到 AppDelegate+EaseMob.h 文件中的 didRegisterForRemoteNotificationsWithDeviceToken: 方法里。


希望可以帮到一部分人。

相关文章

网友评论

      本文标题:iOS | 集成极光推送遇到的坑

      本文链接:https://www.haomeiwen.com/subject/ajaleftx.html