ionic-team / capacitor-plugins

Official plugins for Capacitor ⚡️
518 stars 585 forks source link

Browser.open(url) opens Youtube native app In Android #1177

Open JeetuChoudhary opened 2 years ago

JeetuChoudhary commented 2 years ago

Bug Report

Capacitor Version

   Capacitor Doctor

Latest Dependencies:

  @capacitor/cli: 4.2.0
  @capacitor/core: 4.2.0
  @capacitor/android: 4.2.0
  @capacitor/ios: 4.2.0

Installed Dependencies:

  @capacitor/cli: 4.2.0
  @capacitor/ios: 4.2.0
  @capacitor/core: 4.2.0
  @capacitor/android: 4.1.0

[success] Android looking great! �
[error] Xcode is not installed

Platform(s)

Android Android version: 11 Device: Redmi K20 pro

Current Behavior

If I am trying to open an embed youtube URL into InAppBrowser. The first time it opens it in Youtube native app rather than opening it in InAppBrowser. After that, It is opening it in InAppBrowser which is not consistent. It does it sometimes.

image

Expected Behavior

It should open in InAppBrowser.

Code Reproduction

Here is the link to the repo with code reproduction

Other Technical Details

"@capacitor/browser": "^4.0.0"

Ionic:

   Ionic CLI                     : 6.20.1 (C:\nvm\v14.15.5\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 6.2.6
   @angular-devkit/build-angular : 14.2.2
   @angular-devkit/schematics    : 14.1.3
   @angular/cli                  : 14.1.3
   @ionic/angular-toolkit        : 5.0.3

Capacitor:

   Capacitor CLI      : 4.2.0
   @capacitor/android : 4.1.0
   @capacitor/core    : 4.2.0
   @capacitor/ios     : 4.2.0

Utility:

   cordova-res : not installed globally
   native-run  : 1.7.0

System:

   NodeJS : v14.15.5 (C:\Program Files\nodejs\node.exe)
   npm    : 6.14.11
   OS     : Windows 10

Additional Context

Ionitron commented 2 years ago

This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue.

Please see the Contributing Guide for how to create a Code Reproduction.

Thanks! Ionitron 💙

JeetuChoudhary commented 2 years ago

Hello @jcesarmobile. thanks for checking it out. I have added the function which is calling Browser.open() from the capacitor plugin. It works fine in the browser. The issue only comes when I try to use it on android mobile. So, I don't understand what you need here.

jcesarmobile commented 2 years ago

We need a sample app we can run, the link on Ionitron comment explains it

JeetuChoudhary commented 2 years ago

@jcesarmobile I have updated it with the code reproduction repo and some additional info. Check it out.

jcesarmobile commented 2 years ago

The provided sample app doesn't have @capacitor/browser plugin installed nor any code using it.

JeetuChoudhary commented 2 years ago

@jcesarmobile my bad forgot to push the updated commit 😞. It's updated now. Kindly check it out.

jcesarmobile commented 2 years ago

Thanks for the sample app, I could reproduce.

Apparently that's how Android Custom Tabs work, if you have an app installed that register deep links, it will open the app instead of the Custom Tab (the Browser plugin window).

It's possible to hardcode the package when launching the Custom Tabs intent to force using the Custom Tabs window by passing Chrome's package like tabsIntent.intent.setPackage(CUSTOM_TAB_PACKAGE_NAME);. But that will crash on devices that don't have Chrome installed.

I'm marking the issue as feature request as I don't think forcing Chrome package should be the default behavior.

lochehong commented 1 year ago

any updates on this?

lochehong commented 1 year ago

I found this in your repo.

https://github.com/ionic-team/capacitor-plugins/pull/719/commits/d5e4102adbaf340a28019903d711418a634bbf75

@jcesarmobile what do you think? it hasn't been released.

JeetuChoudhary commented 1 year ago

I was wondering if you could give me an update on the feature request. I've been working on a project that's been impacted by this issue, and I'd like to know if there's any ETA on a resolution.

I came across pull request #719 and it looks like it addresses the issue, but I was curious if it's going to be merged into the main branch. It would save me some time and effort if it was. Creating a local build allows me to make all those changes manually. But, Our builds are created using CI/CD, so it is tricky.