Android上的Ionic InAppBrowser无法导航到自定义网址方案 [英] Ionic InAppBrowser on Android doesn't navigate to custom Url Scheme

查看:155
本文介绍了Android上的Ionic InAppBrowser无法导航到自定义网址方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行设置,在该程序中,我在目标为'_blank'的InAppBrowser插件中打开了一个网址.插件Deeplinks也已安装和配置.

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();
    }
});

我将其简化为仅显示重要部分.打开的网址是 https://www.voan.ch/wfl/(只是真正实现之前的模拟)

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)

预期的行为是,单击URL上的每个链接,应用程序内的浏览器实例应关闭.此功能可以在iOS上正常运行,但不能在Android上运行.该事件只是不触发.如果我将其中一个网址更改为<a href="https://www.google.com">CANCEL</a>,则事件被触发.

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.

推荐答案

对此的支持已在最新的 pr

the support for this was added in latest pr

要使用它,您将需要两件事:

to use it you will need 2 things:

例如允许whatsapp自定义方案和Twitter

for example to allow whatsapp custom scheme and twitter

  • 使用您要支持的自定义方案添加新的config.xml首选项: <preference name="AllowedSchemes" value="whatsapp,twitter" />`
  • 添加事件监听器customcheme: inAppBrowserRef.addEventListener('customscheme', function (event) { //do whatever you want here like: window.open(event.url, "_system"); });
  • 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"); });

这篇关于Android上的Ionic InAppBrowser无法导航到自定义网址方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆