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

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

作者: jsoonli | 来源:发表于2016-06-20 16:21 被阅读865次

    在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

    相关文章

      网友评论

          本文标题:iOS10 远程推送点击后跳转不到指定的页面

          本文链接:https://www.haomeiwen.com/subject/igvwdttx.html