iOS10 远程推送点击后跳转不到指定的页面

2016-06-20  本文已影响865人  jsoonli

在iOS10上多了一个UNUserNotificationCenter,可以在

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    center.delegate = self;
}

然后实现方法

- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
    completionHandler(UNNotificationPresentationOptionBadge);
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler {
      NSDictionary *userinfo = response.notification.request.content.userInfo;

      if (userinfo && [userinfo isKindOfClass:[NSDictionary class]]) {
      }
}

使用时最好判断一下版本

#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_0

官方文档:
https://developer.apple.com/reference/usernotifications/unusernotificationcenter

WWDC16 Session707:
Introduction to Notifications

WWDC16 Session708:
Advanced Notifications

WWDC16 Session724:
What's New in the Apple Push Notification Service

上一篇下一篇

猜你喜欢

热点阅读