【发布时间】:2019-11-07 11:59:03
【问题描述】:
当我通过myapp://param1=abc 打开我的应用程序时,不会调用 open url 函数。
正如 Apple 文档所述,我添加了函数 didFinishLaunchingWithOptions 和 willFinishLaunchingWithOptions 使其成为 true,但它仍然没有被调用。应用程序完美打开,但没有调用函数 open url 我无法获取 param1
这是我的AppDelegate 文件:
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
return true
}
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
return true
}
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// Here doesn't come! :(
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
知道会发生什么吗?
谢谢!
【问题讨论】:
-
你必须在 didFinishLaunchingWithOptions() 中检查 launchOptions 字典。
-
你在info.plist中添加了urlScheme吗?
-
@Jitendra launchOption 字典在 didFinishLaunchingWithOptions() 中为零。
-
@PGDev 我在 info.plist 中添加了 urlScheme