JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
14.85k stars 1.08k forks source link

Way to open external activity or app from compose multiplatform for android,ios #4750

Closed prabinshrestha closed 2 weeks ago

prabinshrestha commented 2 weeks ago

Hello, Is there any ways or workaround or sample to open external activity or app through intent for android and other implementation for ios using same codebase within compose multiplatform. If yes, please provide the hint.

Sanlorng commented 2 weeks ago
interface PlatformState {
    fun launchApp(id: String)
    fun launchWindow(route: String)
}

expect fun rememberPlatformState()
actual fun rememberPlatformState () = Android PlatformState()

private class AndroidPlatformState: PlatformState {
}
igordmn commented 2 weeks ago

Using an expect/actual function is the way to solve this.

How to open an activity on Android target, see the Android and Jetpack Compose documentation, or ask in the #compose-android Slack channel.