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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With