Search code examples
iosswiftdeep-linking

Xcode 11 deeplink seems to be different since it does not call the function from AppDelegate


I was trying to work with the deeplinks in Xcode 11 and found that app is not calling

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    return true
}

above function anymore when I try to use the deeplink but instead calling below function.

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {

}

In this case what is the relevance of this function anymore?

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        return true
    }

Does anyone has worked on deeplink for Xcode 11 or faced similar decision issues? Could you please guide me in this problem?


Solution

  • The method scene(_ scene:, openURLContexts URLContexts:) is called on iOS >= 13.

    The older method application(_ app:, open url:, options:) is called on iOS < 13.

    So, unless you are only targetting iOS 13, you have to handle the URL in both methods.