2015-03-02 34 views
8

我希望你能幫我找到我的問題。PhoneGap和WhatsApp

我正在開發一個應該使用WhatsApp的應用程序。此應用程序使用HTML5,CSS3和Javascript。我使用這個鏈接與WhatsApp的發送消息:

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

這個環節的工作完全當您直接使用瀏覽器,但是當我使用的PhoneGap我有這樣的錯誤:

網:: ERR_UNKNOWN_URL_SCHEME

我測試了一些問題,但不起作用。我也檢查了文件,但沒有任何...

你能幫我嗎?

感謝

編輯

這裏是解決我的問題(感謝@jcesarmobile):

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

非常感謝:)

回答

11

此行添加到您的config.xml

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

或者使用社交共享插件

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> 
+1

非常感謝你。它的工作:)。我只是使用這一行:'' – 2015-03-02 19:13:01

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

這個工作了PhoneGap的IOS

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

爲Android。

0

第一,更重要的,這行添加到您的config.xml

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

使用後的代碼:

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