Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[url_launcher] Adds documentation that a launch needs to be triggered by a user action #5143

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions packages/url_launcher/url_launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.1.15

* Adds documentation to the `launchUrl` method that a launch needs to be triggered by a user action.

## 6.1.14

* Updates documentation to mention support for Android Custom Tabs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ import 'type_conversion.dart';
/// - "_self" opens the new URL in the current tab.
/// Default behaviour when unset is to open the url in a new tab.
///
/// Some web browsers, such as Safari, may prevent URL launching if it is not
Copy link
Member

Choose a reason for hiding this comment

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

I normally add these notes to the README of the web package under a "Limitations of the web platform" section (example, very similar to the Autoplay problem!), but I'm not sure if those are discoverable enough, since they're by default "hidden" in pub

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree that it's a bit hidden and the README.md would also a good place 👍 If you or @stuartmorgan like the approach with README.md more, I could copy the structure of the video_player package (having a short note that there are limitations on web in the main README and a more detailed description in url_launcher_web package).

Copy link
Contributor

Choose a reason for hiding this comment

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

I think putting the long explanation in the README and then referencing that here is probably the best option.

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 made the following changes:

  • Adding a link about the web limitations in the "Configuration" section of the README.md of url_launcher (like video_player has), please let me know if this is the wrong location
  • Adding a new section "Limitations on the Web platform" with the detailed documentation in the README.md of the url_launcher_web package
  • Just referencing to this limitation in the launchUrl method

/// triggered by a user action (e.g. a button click). Even if a user triggers a
/// launch through a button click, if there is a delay due to awaiting a
/// [Future] before the launch, the browser may still block it. This is because
/// the browser might perceive the launch as not being a direct result of user
/// interaction, particularly if the Future takes too long to complete. In such
/// cases, you can use the [webOnlyWindowName] argument, setting it to "_self",
/// to open the URL within the current tab. Another approach is to ensure that
/// the [uri] is synchronously ready.
///
/// Returns true if the URL was launched successful, otherwise either returns
/// false or throws a [PlatformException] depending on the failure.
Future<bool> launchUrl(
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/packages/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.14
version: 6.1.15

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