Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
[url_launcher] Document why canLaunch can return false on Android API…
Browse files Browse the repository at this point in the history
… 30 (#3040)

This PR adds extra documentation to the canLaunch method, explaining that (from Android API 30) false is returned when the package visibility is not managed properly.

Starting from Android API 30, apps should explicitly list which other apps it wants to query or interact with, by specifying them in the AndroidManifest.xml file. More information can be found in the Manage package visibility article in the Android documentation.
  • Loading branch information
mvanbeusekom committed Sep 24, 2020
1 parent 705ae77 commit 88acaf4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/url_launcher/url_launcher/CHANGELOG.md
@@ -1,3 +1,7 @@
## 5.7.2

* Add API documentation explaining the [canLaunch] method returns `false` if package visibility (Android API 30) is not managed correctly.

## 5.7.1

* Keep handling deprecated Android v1 classes for backward compatibility.
Expand Down
5 changes: 5 additions & 0 deletions packages/url_launcher/url_launcher/lib/url_launcher.dart
Expand Up @@ -109,6 +109,11 @@ Future<bool> launch(

/// Checks whether the specified URL can be handled by some app installed on the
/// device.
///
/// On Android (from API 30), [canLaunch] will return `false` when the required
/// visibility configuration is not provided in the AndroidManifest.xml file.
/// For more information see the [Managing package visibility](https://developer.android.com/training/basics/intents/package-visibility)
/// article in the Android docs.
Future<bool> canLaunch(String urlString) async {
if (urlString == null) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion packages/url_launcher/url_launcher/pubspec.yaml
Expand Up @@ -2,7 +2,7 @@ name: url_launcher
description: Flutter plugin for launching a URL on Android and iOS. Supports
web, phone, SMS, and email schemes.
homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher
version: 5.7.1
version: 5.7.2

flutter:
plugin:
Expand Down

0 comments on commit 88acaf4

Please sign in to comment.