如何使用离子中的意图打开另一个应用程序? [英] How can I open another app using intents in ionic?

查看:112
本文介绍了如何使用离子中的意图打开另一个应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了以下标记,但它没有做任何事情

I have tried the following markup but it does nothing

<ion-header-bar class="bar-dark">
    <h1 class="title title-left">App Title</h1>
    <a class="button rate-me button-light" href="amzn://apps/here">Rate</a>
</ion-header-bar>

我想可能是因为没有安装处理意图的应用程序。所以,我尝试了以下标记:

I thought may be it is because no app to handle the intent is installed. So, I tried the following markup:

<ion-header-bar class="bar-dark">
    <h1 class="title title-left">App Title</h1>
    <a class="button rate-me button-light" href="http://link-to/app/here">Rate</a>
</ion-header-bar>

然而,在我的Android设备上点击任何一个都没有任何反应。当我在浏览器中尝试应用程序时,我可以打开链接。我是否需要添加任何权限才能使其在Android上运行?

However, nothing happens on clicking on any of them on my android device. I can open the link when I try the app in my browser through. Do I need to add any permissions to make it work on android?

推荐答案

我认为最简单的方法是添加 target ='_ system'< a> 元素。
您还需要安装Cordova插件InAppBrowser( org.apache.cordova.inappbrowser )。

I think the easiest way is to add target='_system' to the <a> element. You will also need to install Cordova plugin InAppBrowser (org.apache.cordova.inappbrowser).

但请注意,如果缺少应用程序,它将打开系统Web浏览器。

Note however that if the app is missing, it will open the system web browser.

这将打开系统Web浏览器向包管理器询问在其intent过滤器中使用URL方案的任何应用程序。 WebView 不会自行完成。如果你想在 WebView 中进行,你需要覆盖 shouldOverrideUrlLoading

This opens the URL in the system web browser which asks the package manager for any apps using the URL scheme in their intent filters. WebView does not do it on its own. If you want to do it in WebView you need to override shouldOverrideUrlLoading.

我刚刚发现,自Cordova 3.4以来,InAppBrowser根本不处理< a> 标签。 0左右。请参阅: https://issues.apache.org/jira/browse/CB-6747所以你需要解决它。或者您可以在锚标记中指定 onclick =window.open('http:// link-to / app /','_ system')

I just found out that the InAppBrowser does not handle <a> tags at all since Cordova 3.4.0 or so. See: https://issues.apache.org/jira/browse/CB-6747 So you will need to work around it. Or you can just specify onclick="window.open('http://link-to/app/', '_system')" in the anchor tag.

这篇关于如何使用离子中的意图打开另一个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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