Ionic InAppBrowser on Android doesn't navigate to custom Url Scheme

大憨熊 提交于 2020-01-01 19:41:50

问题


I am having a setup, where I open a url in the plugin InAppBrowser with target '_blank'. The plugin Deeplinks is also installed and configured.

const browser: InAppBrowserObject = this.iab.create(url, '_blank', <InAppBrowserOptions>{
    location: "no",
    toolbar: "no",
    footer: "no"
});

browser.on('loadstart').subscribe((event: InAppBrowserEvent) => {
    console.log(event);

    if (event.url.indexOf('wflwr://payment/success') > -1) {
        browser.close();
    }

    if (event.url.indexOf('wflwr://payment/cancel') > -1) {
        browser.close();
    }

    if (event.url.indexOf('wflwr://payment/error') > -1) {
        browser.close();
    }
});

I shortened it to show just the important parts. The url which is opened is https://www.voan.ch/wfl/ (it is just a Mock before the real implementation)

The expected behaviour is, that on a click on each of the links on the url, the browser instance inside the app should close. This works as intended on iOS, but not on Android. The event is just not triggered. If I change one of the urls to e.g. <a href="https://www.google.com">CANCEL</a>, then the Event gets triggered.


回答1:


the support for this was added in latest pr

to use it you will need 2 things:

for example to allow whatsapp custom scheme and twitter

  • add new config.xml preference with the custom schemes you want to support: <preference name="AllowedSchemes" value="whatsapp,twitter" />`
  • add event listeners customscheme: inAppBrowserRef.addEventListener('customscheme', function (event) { //do whatever you want here like: window.open(event.url, "_system"); });


来源:https://stackoverflow.com/questions/51908666/ionic-inappbrowser-on-android-doesnt-navigate-to-custom-url-scheme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!