-1

I want to launch opened app B externally from ionic app A using custom URL scheme.

Solutions Tried

  1. Plugin In App Browser, is able to launch external app in the ionic app itself instead of launching the opened external app.
const target = '_system';
    let url = 'abc123://abc.com/mobile/details/' + Id;

    const options: InAppBrowserOptions = {
      zoom: 'no',
      location: 'no',
      hidden: 'yes'
    };

    this.loadingProvider.dismiss();
    this.inAppBrowserRef = this.inAppBrowser.create(url, target, options);
  1. Plugin App Launcher. For android, it is able to launch external app but use package name instead of custom URL scheme
Lily.T
  • 123
  • 3
  • 14

2 Answers2

0

I use an anchor tag in my template, and set target="_blank". This is from an Ionic 5 app, but I've only tested in the full iOS build, I don't have an Android one yet. I'm also using Capacitor, but I don't think that changes the browser behavior.

<a [href]="website" target="_blank">{{ website }}</a>

The target="_blank" causes it to open the URL in the main os browser. The main browser should then handle your custom link.

cjd82187
  • 3,468
  • 3
  • 15
  • 19
  • Hi, thanks for your suggestion. However I cannot use anchor tag. I need to pass dynamic param to the custom link, therefore I need to handle it in .ts page. InAppBrowser & App Launcher I've tried and all of them will launch app B in ionic app A itself instead of launch app B externally that already opened. – Lily.T Jul 14 '20 at 12:54
  • My href was dynamic as well, its set at the component initialization, but there is no reason that my `website` variable couldn't change over time based on other inputs. `window.open` should try and open in a new "tab" like `target="_blank"` does, but I can't verify right now. – cjd82187 Jul 14 '20 at 13:05
  • ```window.open``` will add "http" in front of my custom URL in android and causing ERR_UNKNOWN_URL_SCHEME error – Lily.T Jul 15 '20 at 00:55
0

If you have custom URL to open use

window.open('Your URL','_system');

in your code. This can be work in both platform Android and ios Perfectly.

Jain Bhavesh
  • 558
  • 5
  • 17