From c32e918f30d3421fb118beae43b4838967267ab7 Mon Sep 17 00:00:00 2001 From: reasje Date: Fri, 30 Aug 2024 13:56:36 +0330 Subject: [PATCH 1/2] fix: Discord dynamic link --- .../open_dapp/open_dapp_presenter.dart | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart b/lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart index fb12a4fe..ab1c10b4 100644 --- a/lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart +++ b/lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart @@ -230,16 +230,43 @@ class OpenDAppPresenter extends CompletePresenter { final url = await state.webviewController?.getUrl(); final deepLink = navigationAction.request.url; - if (deepLink != null && + collectLog('checkDeepLink:url ${url.toString()}'); + collectLog('checkDeepLink:deepLink ${deepLink.toString()}'); + + // Discord gg for redirecting to App + if (deepLink != null && (deepLink.host == "discord.gg")) { + return await launchDeepLinking(deepLink, allowNavigation: true); + } else if (deepLink != null && url != navigationAction.request.url && - (deepLink.scheme != 'https' && deepLink.scheme != 'http')) { - _launcherUseCase.launchUrlInExternalApp(deepLink); - return NavigationActionPolicy.CANCEL; + (deepLink.scheme != 'https' && + deepLink.scheme != 'http' && + deepLink.scheme != 'data' && + deepLink.toString() != "about:blank")) { + Uri? modifiedDeepLink; + if (deepLink.scheme == 'intent') { + modifiedDeepLink = deepLink.replace(scheme: 'https'); + } + return await launchDeepLinking(modifiedDeepLink ?? deepLink); } return NavigationActionPolicy.ALLOW; } + Future launchDeepLinking(Uri deepLink, + {bool allowNavigation = false}) async { + try { + await _launcherUseCase.launchUrlInExternalApp(deepLink); + } catch (e) { + addError(e.toString()); + return NavigationActionPolicy.ALLOW; + } + if (allowNavigation) { + return NavigationActionPolicy.ALLOW; + } else { + return NavigationActionPolicy.CANCEL; + } + } + injectScrollDetector() { state.webviewController! .evaluateJavascript(source: JSChannelScripts.overScrollScript); From 6c9565dd0e829e8a7999e0f46e4657965443877c Mon Sep 17 00:00:00 2001 From: Reza <53487920+reasje@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:58:11 +0330 Subject: [PATCH 2/2] Update version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 0931ab71..4aeabb32 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 2.4.9 +version: 2.5.0 environment: sdk: ">=2.19.0 <3.0.0"