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

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)


}

求大神给个提示


在didFinishLaunchingWithOptions中,


// 处理推送 if (launchOptions != nil) { NSDictionary *dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (dictionary != nil) { // 这个字典就是推送消息的userInfo } }

请问,你这个问题解决了吗,我在swift开发的时候也遇到这个问题,不知道怎么搞,求分享,感谢

【热门文章】
【热门文章】