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)
}
求大神给个提示
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在didFinishLaunchingWithOptions中,
请问,你这个问题解决了吗,我在swift开发的时候也遇到这个问题,不知道怎么搞,求分享,感谢