简体   繁体   English

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

[英]VS2015 Cordova Sms Plugin Sms.Send doesn't work in Index.JS (ondeviceReady)

I'm new to Cordova, any help would be appreciated. 我是Cordova的新手,任何帮助将不胜感激。

I created a new Cordova Project in VS2015 and added the Cordova SMS plugin to my project ( https://www.npmjs.com/package/cordova-sms-plugin ). 我在VS2015中创建了一个新的Cordova项目,并将Cordova SMS插件添加到了我的项目( https://www.npmjs.com/package/cordova-sms-plugin )。

I added this code to /www/scripts/index.js function onDeviceReady (as per documentiation for 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);

I debug the project using Debug, Android, Ripple - Nexus (Galaxy) selected options. 我使用Debug,Android,Ripple-Nexus(Galaxy)选定的选项调试项目。 When I place a breakpoint on the sms.send line of code and I add a watch for 'sms.send', I can see the object exists. 当我在代码的sms.send行上放置一个断点并添加“ sms.send”的监视时,我可以看到该对象存在。

When I single step, this line in sms.js seems to be the last line that executes: 当我单步执行时,sms.js中的这一行似乎是执行的最后一行:

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

I then get the following error message in Ripple: 然后,我在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).' “ Sms.send我们似乎缺少一些东西:(虽然您可以填写textarea以便将json对象传递给您要执行的回调,但是这很酷)。”

I can see that all of the objects in that line is defined (success, failure, phone, message, androidIntent, replaceLineBreaks). 我可以看到该行中的所有对象都已定义(成功,失败,电话,消息,androidIntent,replaceLineBreaks)。 When I 'step into' this line, it continues to execute code in ripple.js, but it becomes hard to follow for a person, since there are no line breaks in this file. 当我“进入”这一行时,它将继续执行波纹.js中的代码,但是由于该文件中没有换行符,因此对于一个人来说很难遵循。

What am I doing wrong? 我究竟做错了什么? I've read through all the documentation I can find & searched stackoverflow questions and can't seem to find any solutions to the problem. 我已经阅读了所有可以查找和搜索stackoverflow问题的文档,并且似乎找不到该问题的任何解决方案。

I've uploaded this entire project (zipped), which can be downloaded at: https://drive.google.com/file/d/0BwWgTMh-JLbfNHV0MlE5Yk5IZ3M/view?usp=sharing 我已经上传了整个项目(已压缩),可以在以下位置下载: https : //drive.google.com/file/d/0BwWgTMh-JLbfNHV0MlE5Yk5IZ3M/view?usp=sharing

Thanks in advance 提前致谢

Thank you Cordova team at Microsoft for helping me with an answer: 感谢Microsoft的Cordova团队为我提供的答案:

"Ripple has the ability to emulate some but not all plugins. 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. I tried the bit of sample code you included in the first email. In Ripple, I was able to change the alert by hitting the different buttons. “ Ripple可以模拟某些但不是全部插件。SMS不是它可以完全模拟的插件之一。但是,在弹出的消息中,您确实可以单击“成功”或“失败”按钮,该按钮将报告返回成功发送短信的应用程序(虽然实际上并没有发送消息),但它确实可以让您测试应用程序以查看其对不同结果的行为。我尝试了一些示例代码在第一封电子邮件中,在Ripple中,我可以通过点击不同的按钮来更改警报。

Trying other deployment methods, in both the VS Android Emulator and the Google Emulator they showed failure alert messages that they don't support SMS messages. 尝试使用其他部署方法,在VS Android仿真器和Google仿真器中,它们都显示了不支持SMS消息的失败警报消息。 I then launched it on an Android phone device and it said it was successful. 然后,我在Android手机设备上启动了它,并说它成功了。

So I believe your options are mainly using Ripple to fake sending of messages or using a device for testing." 因此,我相信您的选择主要是使用Ripple来伪造消息发送或使用设备进行测试。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM