Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
fix: Discord dynamic link
Browse files Browse the repository at this point in the history
  • Loading branch information
reasje committed Aug 30, 2024
1 parent 85e4917 commit c32e918
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,43 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {
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<NavigationActionPolicy> 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);
Expand Down

0 comments on commit c32e918

Please sign in to comment.