PhoneGap and WhatsApp

混江龙づ霸主 提交于 2019-12-04 17:49:45

问题


I hope you'll can help me to find an issue to my problem.

I'm developping an application who should use WhatsApp. This application is using HTML5, CSS3 and Javascript. I am using this link to send an message with WhatsApp :

<a href="whatsapp://send?text=Test 1">

This link work perfectly when you use directly a browser but when I use PhoneGap I have a error like this :

net::ERR_UNKNOWN_URL_SCHEME

I have tested some issues but doesn't work. I have also checked the Documentation but nothing...

Can you help me please ?

Thanks

EDIT

Here is the solution to my problem (thanks to @jcesarmobile):

<access origin="whatsapp:*" launch-external="yes" />

Many thanks :)


回答1:


Add this line to your config.xml

<access origin="whatsapp:*" launch-external="yes" />

Or use the social sharing plugin

https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin

<button onclick="window.plugins.socialsharing.shareViaWhatsApp('Message via WhatsApp', null /* img */, null /* url */, function() {console.log('share ok')}, function(errormsg){alert(errormsg)})">msg via WhatsApp (with errcallback)</button>



回答2:


First and more important, add this line to your config.xml

<allow-intent href="whatsapp:*" />

after use the code:

<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>



回答3:


window.location.href = 'whatsapp://send?text=hello world';

this worked for phonegap IOS

window.open("'whatsapp://send?text=hello world'", "_system");

for android.



来源:https://stackoverflow.com/questions/28809408/phonegap-and-whatsapp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!