Skip to content

Commit

Permalink
Call openUrl with a completionCallback, seems to fix a freeze (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin authored Apr 19, 2024
1 parent ea5c159 commit 738ae7d
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Any?, Any>()) {
if (!it) {
println("Could not open $url")
}
}
true
} else { false }
} else {
false
}
}
}

0 comments on commit 738ae7d

Please sign in to comment.