utils/url_launcher: force opening http(s) links in external browser

The (mobile) platform implementations for url_launcher default to
opening any http(s) link inside a webview instead of the platform
browser. This seems to be a longer-time problem for iOS
(https://gitlab.com/famedly/fluffychat/-/issues/519) but very recently
started to affect Android as well.

Force url_launcher to always use an external application (the browser,
most likely, but possibly other apps might handle those links as well)
as opening links from a messaging app in a webview provides terrible UX.

(For instance a link might lead to some webpage where you start to fill
in some info but then you need to ask someone via the messanger but
can't go back without closing the webview and losing all state. Or if
you happen to re-launch FluffyChat via the home-screen than it goes back
to the home view and the webview state is completely lost as well.)
This commit is contained in:
Marcus Hoffmann 2023-02-18 21:42:09 +01:00
parent 8fc8d7dd0f
commit d318a2948f

View file

@ -84,7 +84,9 @@ class UrlLauncher {
? 'xn--$hostPartPunycode'
: hostPart;
}).join('.');
launchUrlString(uri.replace(host: newHost).toString());
// Force LaunchMode.externalApplication, otherwise url_launcher will default
// to opening links in a webview on mobile platforms.
launchUrlString(uri.replace(host: newHost).toString(), mode: LaunchMode.externalApplication);
}
void openMatrixToUrl() async {