compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

iOS Crash: LocalUriHandler not handling phone URIs

Open yuroyami opened this issue 2 years ago • 4 comments
trafficstars

(@mazunin-v-jb : moved versions here) Kotlin version: 1.9.21 Compose-jb: 1.5.11 OS: iOS 16.3.1 arm64

Consider the following code:

val websiteUri = "https://www.example.com"
val phoneUri = "tel:+29429402"

val uriHandler = LocalUriHandler.current
uriHandler.openUri(websiteUri) //Works fine on Android and iOS
uriHandler.openUri(phoneUri) <--- Crashes

The syntax tel: + phone number is used for Android only (afaik), however, it is not working on iOS. I haven't tested yet whether the iOS syntax (tel:// + phone number) is handled on iOS (probably cannot be handled on Android if it works on iOS). The LocalUriHandler needs to route both syntaxes to their proper handlers on each platform, replacing tel: with tel:// for iOS, and removing the two slashes if it is being routed to Android from tel:// syntax.

In order to launch a telephony URI for iOS, I use this code for now:

        if let phoneURL = URL(string: "tel://\(phoneNumber)") {
            UIApplication.shared.open(phoneURL, options: [:], completionHandler: nil)
        }

yuroyami avatar Nov 24 '23 17:11 yuroyami

Hello, thank you for submitting the issue. Could you please also provide the log crash?

mazunin-v-jb avatar Nov 27 '23 13:11 mazunin-v-jb

@yuroyami I tried to reproduce it on 1.5.11 Compose (1.9.21 Kotlin) on the clean project made from that template and it worked as expected. Could you please also provide the reproducible example and the following information? Versions - Kotlin version*: - Compose Multiplatform version*: - OS version(s)* (required for Desktop and iOS issues): - OS architecture (x86 or arm64):

mazunin-v-jb avatar Dec 04 '23 10:12 mazunin-v-jb

@mazunin-v-jb I am away from my work station for quite some while but as far as I remember, the issue occurred while I was using a phone number that contains white spaces and parentheses. I did not try using a phone number without white spaces or the parentheses.

Kotlin version: 1.9.21 Compose-jb: 1.5.11 OS: iOS 16.3.1 arm64

yuroyami avatar Dec 25 '23 09:12 yuroyami

Thank you for your answer. As far as I remember, I've tried just a number without any special symbols like you described. I'll take a look.

mazunin-v-jb avatar Jan 16 '24 14:01 mazunin-v-jb

Hello, @yuroyami! Sorry for long responding. I've tried to dig dipper into this problem, so I've created a reproducer with many cases of phone numbers. Could you please check it? For me, it works as expected on both iOS and Android.

Also, for iOS testing, please use a physical device (iPhone or iPad). iOS Simulator can't forward tel:/ uri to phone app cause it doesn't have it. Maybe that was the reason for different behavior in our cases.

mazunin-v-jb avatar Feb 21 '24 21:02 mazunin-v-jb

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

okushnikov avatar Jul 14 '24 15:07 okushnikov