Skip to content

Commit

Permalink
Fix external app link handling for in-app browser (#1186)
Browse files Browse the repository at this point in the history
  • Loading branch information
micahmo authored Mar 11, 2024
1 parent 1102a31 commit d9275a5
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/utils/links.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,19 @@ void _openLink(BuildContext context, {required String url}) async {
),
);
} else if (state.browserMode == BrowserMode.inApp) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => WebView(url: url),
),
);
// Check if the scheme is not https, in which case the in-app browser can't handle it
Uri? uri = Uri.tryParse(url);
if (uri != null && uri.scheme != 'https') {
// Although a non-https scheme is an indication that this link is intended for another app,
// we actually have to change it back to https in order for the intent to be properly passed to another app.
url_launcher.launchUrl(uri, mode: url_launcher.LaunchMode.externalApplication);
} else {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => WebView(url: url),
),
);
}
}
}

Expand Down

0 comments on commit d9275a5

Please sign in to comment.