Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[url_launcher] Update README discussion of permissions
Improves the README section about query permissions:
- Removes http/https from the examples; we don't actually expect people
  to query for http(s) support in general (since generally a browser can
  assumed to be available), so it's an odd thing to show.
- Updates the comments in the Android example to clarify that it's about
  querying for support, not launching.
- Makes the iOS and Android sections have parallel structure so they are
  easier to read.

Fixes flutter/flutter#102630
  • Loading branch information
stuartmorgan-g committed Apr 27, 2022
commit bec6dafda7f36cbe9d02c35c72d1ef390166dbe5
5 changes: 5 additions & 0 deletions packages/url_launcher/url_launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 6.1.1

* Updates README section about query permissions to better reflect changes to
`canLaunchUrl` recommendations.

## 6.1.0

* Introduces new `launchUrl` and `canLaunchUrl` APIs; `launch` and `canLaunch`
Expand Down
35 changes: 16 additions & 19 deletions packages/url_launcher/url_launcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,55 +43,52 @@ See the example app for more complex examples.
## Configuration

### iOS
Add any URL schemes passed to `canLaunchUrl` as `LSApplicationQueriesSchemes` entries in your Info.plist file.
Add any URL schemes passed to `canLaunchUrl` as `LSApplicationQueriesSchemes`
entries in your Info.plist file, otherwise it will return false.

Example:
```
```xml
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
<string>http</string>
<string>sms</string>
<string>tel</string>
</array>
```

See [`-[UIApplication canOpenURL:]`](https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl) for more details.

### Android

Starting from API 30 Android requires package visibility configuration in your
`AndroidManifest.xml` otherwise `canLaunchUrl` will return `false`. A `<queries>`
Add any URL schemes passed to `canLaunchUrl` as `<queries>` entries in your
`AndroidManifest.xml`, otherwise it will return false in most cases starting
on Android 11 (API 30) or higher. A `<queries>`
element must be added to your manifest as a child of the root element.

The snippet below shows an example for an application that uses `https`, `tel`,
and `mailto` URLs with `url_launcher`. See
[the Android documentation](https://developer.android.com/training/package-visibility/use-cases)
for examples of other queries.

Example:
``` xml
<queries>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<!-- If your app makes calls -->
<!-- If your app checks for call support -->
<intent>
<action android:name="android.intent.action.DIAL" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GaryQian Are these actually right? They were added by a community-submitted PR that was based on comments from plugin clients in issue reports, but looking at them again after having more familiarity with the Android implementation it seems questionable.

Since the implementation of canLaunchUrl is always just android.intent.action.VIEW with a URL, shouldn't all of the queries be

  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="{whatever scheme here}" />
  </intent>

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've only been recently added as owner of this plugin, so I am actually unclear about this particular question.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blasten Are you familiar with the details of how query specification is supposed to work? Is my expectation that it should match the actual intent query we are going to make (here) correct?

Alternately, @GaryQian you could try experimenting locally to see if you can reproduce canLaunchUrl failing for various cases listed in this README section, and then if the query permission format I suggested above is all we need in each case to make it work? It could be a way to get to know this part of the plugin first-hand :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated to always use VIEW then, matching our implementation. PTAL.

<data android:scheme="tel" />
</intent>
<!-- If your sends SMS messages -->
<!-- If your app checks for SMS support -->
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="smsto" />
</intent>
<!-- If your app sends emails -->
<!-- If your app checks for email support -->
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
```

See
[the Android documentation](https://developer.android.com/training/package-visibility/use-cases)
for examples of other queries.

## Supported URL schemes

The provided URL is passed directly to the host platform for handling. The
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@

<!-- Provide required visibility configuration for API level 30 and above -->
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
Expand Down
2 changes: 1 addition & 1 deletion packages/url_launcher/url_launcher/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for launching a URL. Supports
web, phone, SMS, and email schemes.
repository: https://github.com/flutter/plugins/tree/main/packages/url_launcher/url_launcher
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22
version: 6.1.0
version: 6.1.1

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down