Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deeplink in IOS #382

Open
ghasemdev opened this issue Mar 27, 2024 · 1 comment
Open

Deeplink in IOS #382

ghasemdev opened this issue Mar 27, 2024 · 1 comment
Labels
deeplink docs Improvements or additions to documentation

Comments

@ghasemdev
Copy link

ghasemdev commented Mar 27, 2024

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

```swift
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()
    }
}
@DevSrSouza DevSrSouza added deeplink docs Improvements or additions to documentation labels Apr 7, 2024
@DevSrSouza
Copy link
Collaborator

DevSrSouza commented Apr 7, 2024

@ghasemdev there is no currently built-in way of handling deeplink uris in voyager. The issue #387 has a example how you can handle this your self with replaceAll for example. Also this library from the same author of the issue show how to easily handle deeplink with Voyager and Compose KMP https://github.com/theolm/Rinku

We plan to add better docs for deeplink examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deeplink docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants