android jetpack compose – Deeplink in IOS With Voyager KMP


I need to implement IOS deep link with URL Scheme
but how i can connect that native swift code to voyager.
In docs they said add this function to AppDelegate (how can create this delegate class and connect to other class)

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()
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *