app关闭时点击推送消息实现页面跳转



 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        //推送注册
        var str:NSString = UIDevice.currentDevice().systemVersion
        var version:Float = str.floatValue

        if version >= 8.0 {
            APService.registerForRemoteNotificationTypes(UIUserNotificationType.Badge.rawValue | UIUserNotificationType.Sound.rawValue | UIUserNotificationType.Alert.rawValue, categories: nil)
        } else {
            APService.registerForRemoteNotificationTypes(UIRemoteNotificationType.Badge.rawValue | UIRemoteNotificationType.Sound.rawValue | UIRemoteNotificationType.Alert.rawValue, categories: nil)
        }


        APService.setupWithOption(launchOptions)



        if launchOptions != nil {

                isLauncheByNotification = true

            }

        return true
    }

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {


 var user = userInfo as NSDictionary

    var aps = user.valueForKey("aps") as! NSDictionary

    var str = aps.valueForKey("alert") as! String



    if isLauncheByNotification == true {
    //post消息没有启动
        NSNotificationCenter.defaultCenter().postNotificationName("push", object: nil, userInfo: userInfo)

    }

    APService.handleRemoteNotification(userInfo)
    completionHandler(UIBackgroundFetchResult.NewData)


}

求大神给个提示

ios 极光推送 swift

xuelide 9 years, 5 months ago

在didFinishLaunchingWithOptions中,


 
// 处理推送 if (launchOptions != nil) { NSDictionary *dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (dictionary != nil) { // 这个字典就是推送消息的userInfo } }
我上头有神 answered 9 years, 5 months ago

Your Answer