
我在dIDFinishLaunchingWithOptions中添加了一些代码.但它不起作用.非常感谢你如果有人可以提供帮助.
@H_502_13@func application(_ application: UIApplication,dIDFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let activityDic = launchOptions?[UIApplicationLaunchOptionsKey.userActivityDictionary] if activityDic != nil { // Continue activity here self.window?.rootVIEwController?.restoreUserActivityState(activityDic as! NSUserActivity) } return true}func application(_ application: UIApplication,continue userActivity: NSUserActivity,restorationHandler: @escaPing ([Any]?) -> VoID) -> Bool { if userActivity.activityType == NSUserActivityTypebrowsingWeb { if let controller = UIStoryboard(name: "Main",bundle: nil).instantiateVIEwController(withIDentifIEr: "xxx") as? XXXtableVIEwController { if let window = self.window,let rootVIEwController = window.rootVIEwController { var currentController = rootVIEwController while let presentedController = currentController.presentedVIEwController { currentController = presentedController } currentController.present(controller,animated: true,completion: nil) } } } return true}解决方法 将此代码放入dIDFinishLaunchingWithOptions函数以在应用程序启动时打开URL(Swift 3代码): @H_502_13@if let url = launchOptions?[UIApplicationLaunchOptionsKey.url] as? URL { //Deeplink // process url here } else if let activityDictionary = launchOptions?[UIApplicationLaunchOptionsKey.userActivityDictionary] as? [AnyHashable: Any] { //Universal link for key in activityDictionary.keys { if let userActivity = activityDictionary[key] as? NSUserActivity { if let url = userActivity.webpageURL { // process url here } } } } 总结以上是内存溢出为你收集整理的ios – 当app不在后台时打开通用链接全部内容,希望文章能够帮你解决ios – 当app不在后台时打开通用链接所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)