react-native-inappbrowser icon indicating copy to clipboard operation
react-native-inappbrowser copied to clipboard

Android: Preferring native apps when possible

Open braincore opened this issue 4 years ago • 1 comments

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?

  • Android device

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.

braincore avatar Oct 13 '21 21:10 braincore

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

jdnichollsc avatar Oct 15 '21 17:10 jdnichollsc