Sendsms插件无法在Phonegap上运行

时间:2012-05-01 11:46:50

标签: javascript jquery android cordova phonegap-plugins

我正在尝试使用“Sendsms”插件发送消息,用于Android上的手机间隙。 但是当我调用该函数时,我收到了这个错误:

    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);

我从here&获得了java代码。添加了权限:

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

并将插件添加到Plugins.xml。

你知道这是什么问题吗?

1 个答案:

答案 0 :(得分:1)

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

相关问题