File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
dwebview/src/iosMain/kotlin/org/dweb_browser/dwebview/engine/DWebDelegate
helper/src/commonMain/kotlin/org/dweb_browser/helper Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -57,17 +57,22 @@ private fun DWebViewEngine.hookDeeplink(request: NSURLRequest): Boolean {
5757 val scheme = url?.scheme ? : " http"
5858 if (url != null && ! isWebUrlScheme(scheme)) {
5959 if (scheme == " dweb" ) {
60- lifecycleScope.launch {
61- remoteMM.nativeFetch(url.absoluteString!! )
60+ return when (val urlStr = url.absoluteString) {
61+ null -> false
62+ else -> {
63+ lifecycleScope.launch {
64+ remoteMM.nativeFetch(urlStr)
65+ }
66+ true
67+ }
6268 }
63- return true
6469 }
6570
6671 // 无法使用 uiApp.canOpenURL,因为没有在 info.plist 注册特殊scheme,会导致无法打开scheme链接
6772 // 无法使用 uiApp.openURL,因为当前kotlin对接的iOS openURL已经失效,需要自己对接 open 方法
6873 // val uiApp = remoteMM.getUIApplication()
6974 // 必须排除 dweb+https 这类,否则会导致dweb app无法启动
70- if (url. scheme? .startsWith(" dweb+" ) == false ) {
75+ if ( scheme.startsWith(" dweb+" ) == false ) {
7176 dwebHelper.openURL(url) { res ->
7277 debugDWebView(" hookDeeplink openURL -> " , res)
7378 }
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public val globalIoScope: CoroutineScope
3838
3939public expect suspend inline fun <T > withMainContext (crossinline block : suspend () -> T ): T
4040public suspend inline fun <T > withMainContextCommon (crossinline block : suspend () -> T ): T {
41- return withContext(Dispatchers . Main .immediate + mainAsyncExceptionHandler) { block() }
41+ return withContext(mainAsyncExceptionHandler) { block() }
4242}
4343
4444public suspend inline fun <T > withIoContext (crossinline block : suspend () -> T ): T {
You can’t perform that action at this time.
0 commit comments