发送短信插件在Phonegap上不起作用

Sendsms plugin not working on Phonegap

本文关键字:Phonegap 不起作用 插件      更新时间:2023-09-26

我正在尝试使用Android上的电话间隙的"Sendsms"插件发送消息。但是当我调用该函数时,我收到此错误:

    Uncaught TypeError: Cannot call method 'send' of undefined at file

这是我正在使用的JS代码:

              function onDeviceReady () {
        $('#send').bind('click', function () {
            alert('Phone: ' + $('#friendName').val() + ' Message: ' +       $('#MessageContent').val());
            window.plugins.sms.send($('#friendName').val(), 
                $('#MessageContent').val(), 
                function () { 
                   alert('Message sent successfully');  
                },
                function (e) {
                    alert('Message Failed:' + e);
                }
            );
        });                         
    }
    document.addEventListener("deviceready", onDeviceReady, false);

我从这里获得了java代码并添加了权限:

    <uses-permission android:name="android.permission.SEND_SMS"/>

并将插件添加到插件.xml。

你知道有什么问题吗?

根据您使用的PhoneGap版本,您可能只需要进入smsplugin.js并将"PhoneGap"的实例替换为"cordova"。