/// App在前台时候回调
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
NSDictionary *userInfo = notification.request.content.userInfo;
[self handleRemoteNotificationForcegroundWithUserInfo:userInfo];
}
/// App在后台时候点击推送调用
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
NSDictionary *userInfo = response.notification.request.content.userInfo;
[self handleRemoteNotificationBackgroundWithUserInfo:userInfo];
}
完成上面三个步骤的设置,对于iOS10的推送设置基本就适配了。要想自定义Notification Content或者实现其他NotificationAction请参考其他文章。这里只是做了对iOS10的适配。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持ASPKU
注:相关教程知识阅读请移步到IOS开发频道。










