phonegap发送短信

来源:互联网 发布:软件脱壳是什么意思 编辑:程序博客网 时间:2024/05/29 07:08

参考文章:

https://github.com/dzy19832006/phonegap-sms-plugin


1、

cmd进入\platforms\android路径下,执行命令:

phonegap local plugin add https://github.com/aharris88/phonegap-sms-plugin.git

2、生成文件:

AndroidManifest.xml

<uses-permission android:name="android.permission.SEND_SMS" />    <uses-feature android:name="android.hardware.telephony" android:required="false" />

\assets\www\cordova_plugins.js

module.exports.metadata = // TOP OF METADATA{    "org.apache.cordova.plugin.sms": "0.1.0"}


\assets\www\plugins\org.apache.cordova.plugin.sms\www\sms.js


\src\org\apache\cordova\plugin\sms\Sms.java


\res\xml\config.xml

<feature name="Sms">        <param name="android-package" value="org.apache.cordova.plugin.sms.Sms" />    </feature>


3、调用

var number = "123456";var message = "cs";//var intent = "INTENT"; //leave empty for sending sms using default intentvar intent = "";var success = function () { alert('Message sent successfully'); };var error = function (e) { alert('Message Failed:' + e); };sms.send(number, message, intent, success, error);
intent属性赋值INTENT,则发送短信的时候,会将短信功能界面调出,如果为空,则直接发送短信


0 0
原创粉丝点击