GoogleChrome / android-browser-helper

The Android Browser Helper library helps developers use Custom Tabs and Trusted Web Activities on top of the AndroidX browser support library.
Apache License 2.0
695 stars 289 forks source link

Add ability to open apps and browsers from TWA #340

Open lunush opened 3 years ago

lunush commented 3 years ago

Is your feature request related to a problem? Please describe. Currently, all links open within TWA and intent:// links don't work.

Describe the solution you'd like Ability to through user outside TWA for all non-app related links. It would be awesome if there would be an option to let user select where they want to open a link, just like in a native app. Opening maps in a selected map application, social media link in an app I want, etc.

Additional context It is possible to open links outside PWA from browsers and WebView. WebView even has a method shouldOverrideUrlLoading that lets developer decide how links should behave. CustomTabs doesn't seem to offer anything. An exception could be execCommand, but I am not an Android/Java developer, so don't understand what to do with it.

If there is at least some way to achieve this behaviour, please share it.

dalexanco commented 2 years ago

We achieved that using :

window.location.replace("deeplinkPattern://myDeeplink");

(deeplinkPattern is referenced in our AndroidManifest as a browsable intent-filter)

tomasdev commented 1 year ago

There may be privacy concerns regarding the intents and deep linking. However, for http/https URLs I wish there was a way to allowlist the URLs that we want "in-app" (within the TWA context) versus "go to default browser"