1

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?

Manish Singh
  • 310
  • 1
  • 5
  • 19

2 Answers2

2

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

That is not correct.

In any given moment, system considers only one or the other call between AppDelegate.openUrl(...) and SceneDelegate.openURLContexts(...).

Which is used and when?

Shortest answer: Whenever SceneDelegate is configured correctly (by adding scene reference to the plist), SceneDelegate's method will be invoked, while completely ignoring (even if you have implemented) AppDelegate's method. Otherwise, AppDelegate method will be invoked.

So, an ios12 runtime can call SceneDelegate method, as much as ios13 can call AppDelegate method. This provides forward- and backward- compatibility. Nobody would want a previously working app in App Store all of a sudden to stop working on an iOS 13 device.

0

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.

Hejazi
  • 16,587
  • 9
  • 52
  • 67