首页 文章

VS2015 Cordova Sms插件Sms.Send在Index.JS(ondeviceReady)中不起作用

提问于
浏览
0

我是科尔多瓦的新手,任何帮助都将不胜感激 .

我在VS2015中创建了一个新的Cordova项目,并将Cordova SMS插件添加到我的项目中(https://www.npmjs.com/package/cordova-sms-plugin) .

我将此代码添加到/www/scripts/index.js函数onDeviceReady(根据插件的文档化):

function onDeviceReady() {
    // Handle the Cordova pause and resume events
    document.addEventListener( 'pause', onPause.bind( this ), false );
    document.addEventListener( 'resume', onResume.bind( this ), false );

    var numberString = "aoeuaeu";
    var bypassAppChooser = true; 

    //CONFIGURATION
    var options = {
        replaceLineBreaks: false,
        android: {
            intent: 'INTENT'  // send SMS with the native android SMS messaging
        }
    };

    var successSMS = function () { alert('Message sent successfully'); };
    var errorSMS = function (e) { alert('Message Failed:' + e); };
    sms.send("0811231234", "Testing123", options, successSMS, errorSMS);

我使用Debug,Android,Ripple - Nexus(Galaxy)选择的选项调试项目 . 当我在sms.send代码行上放置断点并为“sms.send”添加监视时,我可以看到该对象存在 .

当我单步时,sms.js中的这一行似乎是执行的最后一行:

// fire
exec(
    success,
    failure,
    'Sms',
    'send', [phone, message, androidIntent, replaceLineBreaks]
);

然后我在Ripple中收到以下错误消息:

'Sms.send We seem to be missing some stuff :( What is kinda cool though you can fill in the textarea to pass a json object to the callback you want to execute).'

我可以看到该行中的所有对象都已定义(成功,失败,电话,消息,androidIntent,replaceLineBreaks) . 当我进入'这一行时,它继续在ripple.js中执行代码,但是对于一个人来说变得很难,因为这个文件中没有换行符 .

我究竟做错了什么?我已经阅读了所有可以查找和搜索stackoverflow问题的文档,似乎无法找到问题的任何解决方案 .

我上传了整个项目(压缩),可以在以下网址下载:https://drive.google.com/file/d/0BwWgTMh-JLbfNHV0MlE5Yk5IZ3M/view?usp=sharing

提前致谢

1 回答

  • 0

    感谢Microsoft的Cordova团队帮助我解答:

    “Ripple能够模拟一些但不是所有的插件 . SMS is not one of the plugins that it can fully emulate. However, in the message that pops up, you do have the ability to hit the Success or Fail buttons which will report back to the app that it was successful or not in sending the SMS. While that doesn’t actually send a message, it does let you test your app to see how it behaves for different results. 我尝试了你在第一封电子邮件中包含的示例代码 . 在Ripple中,我能够通过点击不同的按钮来改变警报 .

    尝试其他部署方法,在VS Android模拟器和Google模拟器中,他们都显示了不支持短信的失败警报消息 . 然后我在Android手机设备上启动它,它说它成功了 .

    因此,我认为您的选择主要是使用Ripple假冒发送消息或使用设备进行测试 . “

相关问题