cordova 短信插件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cordova 短信插件相关的知识,希望对你有一定的参考价值。

https://www.npmjs.com/package/cordova-sms-plugin

 

https://github.com/cordova-sms/cordova-sms-plugin

Using the Cordova CLI and NPM, run:

cordova plugin add cordova-sms-plugin

It is also possible to install via repo url directly (unstable), run :

cordova plugin add https://github.com/cordova-sms/cordova-sms-plugin.git

html

<input id="numberTxt" placeholder="Enter mobile number" value="" type="tel" />
<textarea id="messageTxt" placeholder="Enter message"></textarea>
<input type="button" onclick="app.sendSms()" value="Send SMS" />

javascript

var app = {
    sendSms: function() {
        var number = document.getElementById(‘numberTxt‘).value;
        var message = document.getElementById(‘messageTxt‘).value;
        alert(number);
        alert(message);

        //CONFIGURATION
        var options = {
            replaceLineBreaks: false, // true to replace \n by a new line, false by default
            android: {
                intent: ‘INTENT‘  // send SMS with the native android SMS messaging
                //intent: ‘‘ // send SMS without open any other app
            }
        };

        var success = function () { alert(‘Message sent successfully‘); };
        var error = function (e) { alert(‘Message Failed:‘ + e); };
        sms.send(number, message, options, success, error);
    }
};

以上是关于cordova 短信插件的主要内容,如果未能解决你的问题,请参考以下文章

Android移动APP开发笔记——Cordova(PhoneGap)通过CordovaPlugin插件调用 Activity 实例

android小知识点代码片段

cordova与ios native code交互的原理

无法在片段内查看接收短信

如何在 Sencha Touch 代码中获取 Cordova 插件的参考

firebase 的短信代码不匹配