iOS 13부터 SceneDelegate를 사용해야 함 하여 대응하기 위해 Scheme호출(DeepLink) 구현 방식이 변경됨

한번 어떻게 변경되었는지 아라보자.

Appdelegate

기존의 경우 ForeGorund, backgorund, notRunning 상태에서

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

다음 메소드를 사용하여 모두 스킴 처리가 가능했음.

SceneDelegate

SceneDelegate의 경우에는

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

다음과 같은 메소드를 제공해주는데 해당 메소드는 foreground, backgorund에서 스킴이 호출된 경우에만 호출되는 함수임

하지만 앱이 NotRunning 상태인 경우에는

Untitled

다음 메소드를 커스텀해주어야함. 스킴 호출한 Deeplink를 읽어오기 위해서는 connectionOptions를 사용함.

if let url = connectionOptions.urlContexts.first?.url{
            let message = "\\(url)"
            os_log(.default,log: .default, "MESSAGE = [%{public}@]", message)
            handleNotRunning(url,scene: scene)
            return
        }

SceneDelegate willConnectTo 메소드 에서 다음과 같이 DeepLink값을 가져올 수 있음.