我有一个应用程序,当用户与另一个用户共享应用程序中的特定内容时,使用深层链接导航到页面.这在第二个用户已经运行的应用程序时有效,但如果应用程序未运行,则只需打开应用程序并保留在主屏幕上.我知道我必须在这里遗漏一些非常简单的东西,但我无法弄明白,也无法在谷歌上找到任何关于此的答案.
我在AppDelegate.swift中的代码:
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
let urlPath : String = url.path as String!
let urlHost : String = url.host as String!
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
if(urlHost != "example.com")
{
print("Call Not From Correct Host. Not Continuing...")
return false
}
if(urlPath == "/articles"){
let article: ArticleDetailsViewController = mainStoryboard.instantiateViewController(withIdentifier: "ArticleDetailsViewController") as! ArticleDetailsViewController
self.window?.rootViewController = article
}
self.window?.makeKeyAndVisible()
return true
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: …Run Code Online (Sandbox Code Playgroud)