Phonegap Builder与Cordova SMS插件

时间:2015-08-27 17:09:52

标签: javascript android cordova phonegap-plugins phonegap-build

我想在http://build.phonegap.com下使用Adobe Phonegap Builder在Phonegap中实现一个App。我想使用插件https://build.phonegap.com/plugins/2420发送短信。

在我的config.xml中:

 <gap:plugin name="com.cordova.plugins.sms" version="0.1.2" /> 

Adob​​e PhoneGap Builder将此插件显示为集成插件。

我的下一步行动是从https://github.com/cordova-sms/cordova-sms-plugin/tree/48d9630下载并添加/www/sms.js并将其包含在index.html中

然后我添加一个JavaScript函数,如Git上的例子:

var message = "Testing SMS by sending it to ";
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("MY Handy number", "sms", options, success, error);

在另一篇文章中我发现替换

var exec = require('cordova/exec'); 

var exec = cordova.exec

可以提供帮助,但不起作用。

1 个答案:

答案 0 :(得分:0)

好的。 我已经“修复”了它。

 

必须先按顺序包含js。
同样重要的是文件sms.js不存在。

在config.xml中 你必须投入:     

就是这样。 :)