ios - app关闭时点击推送消息实现页面跳转
大家讲道理
大家讲道理 2017-04-17 15:18:10
[iOS讨论组]
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)


}

求大神给个提示

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回复(2)
PHP中文网

在didFinishLaunchingWithOptions中,


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

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号