【问题标题】:how to send sms in android using phonegap 2.3.0?如何使用phonegap 2.3.0 在android 中发送短信?
【发布时间】:2013-07-13 18:46:40
【问题描述】:
我已经使用 2.3.0 版本开发了 phonegap 应用程序。这个应用程序也有
许多手机插件,例如下载器,pdfviewer,statusbarnotification,video.Now
我想将短信插件实现到同一个应用程序中。我尝试过
使用此应用程序实现短信插件,但无法正常工作。我觉得这很令人困惑
使用多个版本的cordova。所以请清除我的问题,如何包含
并编写使用phonegap发送短信的发送短信代码以及如何包含短信
插件到我的应用程序中。非常清楚地与我分享答案。在此先感谢
【问题讨论】:
标签:
javascript
cordova
phonegap-plugins
【解决方案1】:
此短信插件适用于 phonegap 2.3.0
SendSmsCordovaPlugin
示例:
<script type="text/javascript">
sendSmsDemo = function() {
cordova.exec(function(winParam) {
// Use the following line if json2 library is present.
// Available from Douglas Crockford's github page here:
// https://github.com/douglascrockford/JSON-js/blob/master/json2.js
console.log( JSON.stringify(winParam) );
alert(winParam.sms_send);
}
, function(error) {
alert("An error has occurred");
console.log("An error has occurred");
// Please refer to previous comment about json2 library.
console.log( JSON.stringify(error) );
}
, "SendSms"
,"SendSms"
, ["TESTNUM", "This is random text."]);
}
</script>