如何在 didFinishLaunchingWithOptions 方法中通过单击通用 link 来检查应用程序是否已打开

How to check if the app had opened by clicking a universal link or not in the didFinishLaunchingWithOptions method

目前我正在做一个 swift 项目。在这里,我使用通用 link 实现了深度 linking 来验证我的电子邮件地址。它工作正常。我需要的是如何通过点击通用link来检查是否打开了应用程序。因为在 didFinishLaunchingWithOptions 方法中,我正在检查用户是否已经登录。如果用户已登录,我将导航到主屏幕,否则导航到登录屏幕。检查发生在

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool

方法。当我点击通用 link 时,我也会在

中收到回调
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool 

方法。在这种方法中,我导航到电子邮件验证屏幕

但问题是当我单击通用 link 时,它会打开我的应用程序并导航到登录屏幕(因为用户未登录),然后立即导航到电子邮件验证屏幕。实际上,我需要的是,如果我通过单击通用 link 进入应用程序,我不需要导航到登录屏幕或主屏幕。请帮助我。

当在 AppDelegate 中使用以下方法触发器打开深度链接时

 func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
      //Enter Logic Here based on your URL
 }

您可以尝试检查 didFinishLaunchingWithOptions 委托中可用的 launchOptions 键

UIApplicationLaunchOptionsURLKey A key indicating that the app was launched so that it could open the specified URL.