Skip to content

[url_launcher] Support requiring non-browser for launchUrl on Android #66721

@daadu

Description

@daadu

Use case

I am implementing OAuth2.0 (for Amazon Alexa, but this could apply for any OAuth provider with similar setup), the provider recommends that the deeplink/applink should be used to authorize, if the app is installed in the device and as a fallback use webview/in-app browser tab.

For iOS the use case is solved with universalLinksOnly option in launch. For Android canLaunch returns true since the applink is of scheme https. Alternative could be to use PackageManager to check if app is installed on device - this requires additional entries in <queries> in AndroidManifest.xml but this is not recommended by Android for just url launch use case.

Proposal

  • add optional onlyNonBrowser (defaults to false) argument to canLaunch method
  • for android: if onlyNonBrowser is true, add FLAG_ACTIVITY_REQUIRE_NON_BROWSER flag to intent before resolveActivity is called docs

Caveats

  • As far as I know this can be only implemented for android platform.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterhas partial patchThere is a PR awaiting someone to take it across the finish linep: url_launcherPlugin to launch external applicationspackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions