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

Check if a browser supports Custom Tabs before trying to open an URL #2282

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

DavidStrausz
Copy link

Adds a new method areCustomTabsSupported to the Browser class and uses the method in the BrowserPluginclass to check if any browser on the device can handle opening an URL via Custom Tabs. If no browser can handle it, fallback to opening the URL in the default browser.

I used the exact method suggested in the official documentation. The documentation also suggests to do this check to avoid ActivityNotFoundException exceptions:

If no browser supporting Custom Tabs is available in the device and you launch a URL using customTabsIntent.launchUrl(context, url), the intent might fail, leading to an ActivityNotFoundException.

Always perform a compatibility check to ensure a better user experience.

You can fallback to a standard ACTION_VIEW Intent to open the URL in any available browser.

This will probably fix some of the exceptions mentioned in this issue: #2036

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant