通过WhatsApp的科尔多瓦分享从内部的WebView点击 [英] Cordova Share via WhatsApp from a click inside WebView

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

问题描述

我有我的应用程序科尔多瓦(5.5.1)所建,我尝试通过WhatsApp的分享网址。
我使用以下协议: WhatsApp的://发送文本=测试

如果我打开我的网站上它的工作移动浏览器。在iOS上它的工作也是如此。

我试图添加此<获得原产=WhatsApp的:*发动外部=YES/> 来我的config.xml中,但它仍然没有工作。

我使用InAppBrowser这是怎么我打开我的WebView

REF VAR = window.open(http://m.estadao.com.br/?load-all=true,_blank,位置=无,工具栏=无,closebuttoncaption =一个,EnableViewPortScale =无);

下面是错误:

不知道如何解决这个问题?


解决方案

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

改变了这种

{

 如果(::)|| url.startsWith(WebView.SCHEME_MAILTO)|| url.startsWith(市场)url.startsWith(地理)其他
            尝试{
                意向意图=新意图(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(URL));
                。cordova.getActivity()startActivity(意向);
            }赶上(android.content.ActivityNotFoundException E){
                LOG.e(LOG_TAG,错误与+网址+:+ e.toString());
            }
        }

)|| url.startsWith(WebView.SCHEME_MAILTO)|| url.startsWith(市场:

 如果(url.startsWith(地理其他人)|| url.startsWith (WhatsApp的:)){
            尝试{
                意向意图=新意图(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(URL));
                。cordova.getActivity()startActivity(意向);
            }赶上(android.content.ActivityNotFoundException E){
                LOG.e(LOG_TAG,错误与+网址+:+ e.toString());
            }
        }

添加此&LT是非常重要的;获得原​​产=WhatsApp的:*的推出,外部=YES/&GT; 在config.xml文件以及<。 / p>

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.

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

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");

Here is the error:

Any idea how to solve this ?

解决方案

I solved it editing the core of plugin InAppBrowser.java

Changed this

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

to

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

It's important to add this <access origin="whatsapp:*" launch-external="yes" /> in your config.xml as well.

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

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