Cordova Share via WhatsApp from a click inside WebView
I have an app built in Cordova (5.5.1) and I am trying to share a URL via WhatsApp. I am using the following protocol:whatsapp://send?text= test
If I open my site in a mobile browser, it works. This works on iOS as well.
I tried to add this one <access origin="whatsapp:*" launch-external="yes"/>
to my config.xml but it still doesn't work.
I am using InAppBrowser and this is how I open my webview
var ref = window.open("http://m.estadao.com.br/?load-all=true", "_blank", "location=no", "toolbar=no", "closebuttoncaption=a", "EnableViewPortScale=no");
Any ideas how to solve this?
source to share
I decided to edit it core 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 one <access origin="whatsapp:*" launch-external="yes" />
to your config.xml file.
source to share