Deeplink in IOS With Voyager KMP

35 views Asked by At

I need to implement deep linking with URL Scheme in iOS, but how can I connect that native Swift code to Voyager? The documentation suggests adding this function to the AppDelegate. How can I create this delegate class and connect it to other classes?

func application(
    _ app: UIApplication, 
    open url: URL, 
    options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
    if let scheme = url.scheme,
        scheme.localizedCaseInsensitiveCompare("com.myApp") == .orderedSame,
        let view = url.host {
        
        var parameters: [String: String] = [:]
        URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems?.forEach {
            parameters[$0.name] = $0.value
        }
        
        redirect(to: view, with: parameters) // this line how navigate with voyager??
    }
    return true
}
@main
struct iOSApp: App {
   var body: some Scene {
       WindowGroup {
           ContentView()
       }
   }
}
struct ContentView: View {
    var body: some View {
        ComposeView().ignoresSafeArea(.keyboard) // Compose has own keyboard handler
    }
}
struct ComposeView: UIViewControllerRepresentable {
    func makeUIViewController(context: Context) -> UIViewController {
        MainViewControllerKt.MainViewController()
    }

    func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}
fun MainViewController() = ComposeUIViewController { App() }
@Composable 
fun App () {
    Navigator(ListScreen()) { navigator ->
        CurrentScreen()
    }
}
0

There are 0 answers