iOS推送通知栏点击,测试版可以打开,正式版不能打开
iOS应用,在真机上测试
推送消息后可以在通知栏点击进入到相应的页面
上传到appstore后再安装,收到消息后点击就不能进入相应的页面了
系统版本iOS10.3 iOS9.3都是一样
我的跳转代码是这样的:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
if (application.applicationState == UIApplicationStateActive) {
[self gotoUrl:userInfo];
}else if (application.applicationState == UIApplicationStateInactive){
[self showPushArticle:userInfo];
}else if (application.applicationState == UIApplicationStateBackground){
[self showPushArticle:userInfo];
}
completionHandler(UIBackgroundFetchResultNewData);
}
[self showPushArticle:userInfo]这个就是跳转的函数
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
}
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert); // 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以设置
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler{
NSDictionary * userInfo = response.notification.request.content.userInfo;
if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
[self showPushArticle:userInfo];
}
// Warning: UNUserNotificationCenter delegate received call to -userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: but the completion handler was never called.
completionHandler(); // 系统要求执行这个方法
}
按照网上说的也添加了这两个方法,但是检测到并没有经过这两个函数
不知道有没有哪位遇到过同样的问题
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在iOS10 之前跳转代码是你写的第一种 didreceive方法 在iOS10之后是后面两种跳转方法,只不过需要遵守代理才能走。