iOS推送踩坑

需求

app收到推送,点击推送消息进入指定页面,常用做法是在didReceiveRemoteNotification方法中加入跳转操作,iOS10使用UNUserNotificationCenterDelegate didReceiveNotificationResponse

app在后台运行收到推送,点击推送,结果都是我们预想的那样。如果我们杀掉app的进程,再次收到推送,点击推送,会发现iOS10之后的系统会正常跳转,iOS10之前的只会进到应用的首页,怎么办?

方法

didFinishLaunchingWithOptions中加入下面的代码

if ([[UIDevice currentDevice].systemVersion floatValue] < 10.0) {
NSDictionary *options = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
if (options) {
[self application:application didReceiveRemoteNotification:options];
}
}

你可能感兴趣的:(iOS推送踩坑)