如何使用phonegap 2.3.0在android中发送短信?

时间:2013-07-12 07:25:05

标签: javascript cordova phonegap-plugins

我使用2.3.0版本开发了phonegap应用程序。此应用程序也有     许多手机插件,如下载器,pdfviewer,statusbarnotification,video.Now     我想将sms插件实现到同一个application.i尝试过     使用此应用程序实现sms插件,但无法正常工作。我很困惑     有多个版本的cordova.So请清楚我的问题,如何包括     并编写发送短信代码,用于使用phonegap发送短信以及如何包含短信     插入到我的应用程序中。非常清楚地与我分享答案。提前谢谢

1 个答案:

答案 0 :(得分:2)

此SMS插件适用于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>