【发布时间】:2015-04-29 08:35:38
【问题描述】:
我想在用户点击推送通知时打开浏览器。
在我的应用委托中,我有:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var json = remoteNotif[UIApplicationLaunchOptionsRemoteNotificationKey] as! NSDictionary
storyboard = UIStoryboard(name: "Main", bundle: nil)
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let navC = storyboard.instantiateViewControllerWithIdentifier("mainNav") as! NavViewController
let data = json.objectForKey("data") as! NSDictionary
let url = data.objectForKey("url") as! String
UIApplication.sharedApplication().openURL(NSURL(string: url)!)
self.window?.rootViewController = navC
self.window?.makeKeyAndVisible()
}
当用户点击推送通知时,这会给我黑屏 20 秒,然后应用程序打开,然后浏览器打开。 如何让点击推送通知只打开浏览器,或者至少打开速度超过 20 秒?
谢谢。
【问题讨论】:
-
这个问题解决了吗?
-
no... 最后用 webView 制作了一个新的 UIViewController
-
好的,感谢您分享替代方式。 :) !
-
你应该在块中得到响应然后尝试。像这样 let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT dispatch_async(dispatch_get_global_queue(priority, 0)) { dispatch_async(dispatch_get_main_queue()) { } }
标签: ios swift apple-push-notifications appdelegate