功能描述:在处理远程推送过程时,收到推送消息后,点击跳转到相应页面 问题描述:在app没启动时,收到推送消息,可以正常跳转;但app在前台或者后台时,无法跳转。经查以下两个代理方法都没有被调用。
-
(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler;
-
(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler;
解决思路: 1.查看是否设置代理 2.查看是否遵守代理协议 这个都没有问题,但还是无法正常回调。 进一步排查,在设置代理后,查看代理,结果为“TencentXGPushAppDelegate”,而非“AppDelegate”。
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
NSLog(@"%@",center.delegate);
基本确定代理方法被XGPush“劫持”了,所以没有走到系统的回调中。查看并搜索代码,代码中并未使用到XGPush,只有在Targets->General->Frameworks,Libraries,and Embedded Content中有引入libXG-SDK.a文件。将libXG-SDK.a文件从Frameworks,Libraries,and Embedded Content中删除或者在工程中将libXG-SDK.a及XGPush.h删除,问题解决。 目前并不清楚将libXG-SDK.a文件从Frameworks,Libraries,and Embedded Content中系统做了什么处理,XGPush没有被主动调用,但它是如何将AppDelegate“劫持”为TencentXGPushAppDelegate的。如有了解的大神,请不吝赐教。谢谢啦