Skip to content

Commit e95c68d

Browse files
authored
fix: depricated openURL API (#687)
1 parent 6089951 commit e95c68d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

composeApp/src/iosMain/kotlin/org/ooni/probe/SetupDependencies.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,20 @@ class SetupDependencies(
358358
}
359359

360360
private fun openUrl(openUrl: PlatformAction.OpenUrl): Boolean {
361-
val url = openUrl.url
362-
return NSURL.URLWithString(url)?.let {
363-
if (UIApplication.sharedApplication.canOpenURL(it)) {
364-
UIApplication.sharedApplication.openURL(it)
361+
val urlString = openUrl.url
362+
return NSURL.URLWithString(urlString)?.let { nsUrlString ->
363+
if (UIApplication.sharedApplication.canOpenURL(nsUrlString)) {
364+
UIApplication.sharedApplication.openURL(url = nsUrlString, options = emptyMap<Any?, Any>(), completionHandler = {
365+
isSuccessfullyOpened ->
366+
if (isSuccessfullyOpened) {
367+
Logger.i { "Successfully opened URL: $urlString" }
368+
} else {
369+
Logger.e { "Failed to open URL: $urlString" }
370+
}
371+
})
365372
return@let true
366373
} else {
367-
Logger.e { "Cannot open URL: $url" }
374+
Logger.e { "Cannot open URL: $urlString" }
368375
return@let false
369376
}
370377
} ?: false

0 commit comments

Comments
 (0)