proyecto26 / react-native-inappbrowser

📱InAppBrowser for React Native (Android & iOS) 🤘
https://www.npmjs.com/package/react-native-inappbrowser-reborn
MIT License
1.31k stars 224 forks source link

Android: Preferring native apps when possible #304

Open braincore opened 2 years ago

braincore commented 2 years ago

This is a change in behavior observed when upgrading from v3.4.0 to v3.6.3. Likely due to a8d1d3df9f151251518ff77ff3799a3003b548f9.

In v3.4.0, when opening a URL, Android would first prompt about other apps that could also be used to open the URL. This behavior was desired. In v3.6.3, the prompt is now skipped in favor of opening in the browser.

Make sure to check the existing issues in this repository

Issue #149 is a request to always use the browser, and likely prompted this change in behavior.

Which platform(s) does your issue occur on?

Solution

NOTE: I do virtually no direct Android development so the following may be incorrect.

The solution is likely here: https://developers.google.com/web/updates/2020/07/custom-tabs-android-11#preferring_native_apps

Unfortunately, the easiest solution is to use FLAG_ACTIVITY_REQUIRE_NON_BROWSER but it targets Android >= 11 which RN does not support.

The next solution to use is: https://developers.google.com/web/updates/2020/07/custom-tabs-android-11#before_android_11

If you think this approach makes sense, I can create a PR. I'd likely add a preferNativeApps flag as a prop.

jdnichollsc commented 2 years ago

A new flag to handle this scenario would be awesome, any pull request is welcome! <3