inactive/Terminated 中的应用程序未调用 openURL 函数

openURL function is not call when application in inactive/Terminated

我在我的应用程序中使用 URL Scheme,为此我使用:

func application(application: UIApplication, openURL url: NSURL,  sourceApplication: String?, annotation: AnyObject) -> Bool {
    print("function called")
    return true
}

当应用程序处于 Background 时它工作正常但是当我点击 URL 并且应用程序处于 Inactive 状态或应用程序不是 运行 时,这个功能不是叫

当应用程序 Terminated 时需要帮助才能使用此功能。 如果不能 那我们还有别的选择吗?

当然可以....

在 didFinishLaunchingWithOptions 中使用密钥 "UIApplicationLaunchOptionsKey"

从 "launchOptions" 获取 URL
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if let url = launchOptions?[UIApplicationLaunchOptionsKey.url] as? URL {
    // do your thing...
}