Hey! how can I open a URL link in KMM?
# multiplatform
a
Hey! how can I open a URL link in KMM?
r
you have to create an implementation for each platform, if Android and iOS androidMain
Copy code
val browserIntent = Intent(
    Intent.ACTION_VIEW,
    Uri.parse(url)
)
context.startActivity(browserIntent)
iosMain
Copy code
import platform.Foundation.NSURL
import platform.UIKit.UIApplication

val url = NSURL.URLWithString(it)
UIApplication.sharedApplication().openURL(url)
❤️ 1
a
Thank you, @Raed Ghazal!
kodee welcoming 1
a
I thin this should work on iOS also (works on Android/Jvm):
Copy code
val uriHandler = LocalUriHandler.current
uriHandler.openUri(websiteUri)
5
♥️ 5
b
It does
r
oh wow thanks for sharing @Anders Carlsen!
483 Views