From 592b80d590c01def7607c4382d6cdc3ec9c4a1ca Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Fri, 19 Apr 2024 18:28:29 +0200 Subject: [PATCH] Call openUrl with a completionCallback, seems to fix a freeze --- .../androidmakers/domain/utils/UrlOpener.ios.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/shared/domain/src/iosMain/kotlin/fr/androidmakers/domain/utils/UrlOpener.ios.kt b/shared/domain/src/iosMain/kotlin/fr/androidmakers/domain/utils/UrlOpener.ios.kt index c25b855d..97bcc1ab 100644 --- a/shared/domain/src/iosMain/kotlin/fr/androidmakers/domain/utils/UrlOpener.ios.kt +++ b/shared/domain/src/iosMain/kotlin/fr/androidmakers/domain/utils/UrlOpener.ios.kt @@ -2,13 +2,24 @@ package fr.androidmakers.domain.utils import platform.Foundation.NSURL import platform.UIKit.UIApplication +import platform.darwin.dispatch_async +import platform.darwin.dispatch_get_main_queue actual class UrlOpener { actual fun openUrl(url: String): Boolean { val urlObj = NSURL(string = url) return if (UIApplication.sharedApplication.canOpenURL(urlObj)) { - UIApplication.sharedApplication.openURL(urlObj) + val application = UIApplication.sharedApplication + + application.openURL(url = urlObj, options = emptyMap()) { + if (!it) { + println("Could not open $url") + } + } true - } else { false } + } else { + false + } } } +