本文介绍了Cordova通过WhatsApp从WebView内点击分享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序是用Cordova(5.5.1)构建的,我正在尝试通过WhatsApp共享Url。
我使用以下协议: whatsapp:// send?text = test

I've my app built with Cordova (5.5.1) and I'm trying to share Url's via WhatsApp.I'm using the following protocol: whatsapp://send?text= test

我打开我的网站在移动浏览器它的工作。

If I open my website on a mobile browser it's working. On iOS it's working as well.

我试图添加这个< access origin =whatsapp:*launch-external = yes/> 到我的config.xml,但它仍然不工作。

I've tried to add this <access origin="whatsapp:*" launch-external="yes" /> to my config.xml but it still not working.

我使用InAppBrowser,打开我的webview

I'm using InAppBrowser and this is how I'm opening my webview

var ref = window.open(http://m.estadao.com.br/?load-all=true ,_blank,location = no,toolbar = no,closebuttoncaption = a,EnableViewPortScale = no);

以下是错误:

任何想法如何解决这个问题?

Any idea how to solve this ?

推荐答案

我解决了它编辑插件InAppBrowser.java的核心

I solved it editing the core of plugin InAppBrowser.java

更改了这个

else if (url.startsWith("geo:") || url.startsWith(WebView.SCHEME_MAILTO) || url.startsWith("market:")){
            try {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
                cordova.getActivity().startActivity(intent);
            } catch (android.content.ActivityNotFoundException e) {
                LOG.e(LOG_TAG, "Error with " + url + ": " + e.toString());
            }
        }

else if (url.startsWith("geo:") || url.startsWith(WebView.SCHEME_MAILTO) || url.startsWith("market:") || url.startsWith("whatsapp:"))  {
            try {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
                cordova.getActivity().startActivity(intent);
            } catch (android.content.ActivityNotFoundException e) {
                LOG.e(LOG_TAG, "Error with " + url + ": " + e.toString());
            }
        }

重要的是添加 < access origin =whatsapp:*launch-external =yes/>

这篇关于Cordova通过WhatsApp从WebView内点击分享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 02:29