Sendsms plugin not working on Phonegap

穿精又带淫゛_ 提交于 2019-12-08 08:14:30

问题


I'm trying to send a message using The "Sendsms"plugin for phone gap on Android. But when I call the function, I get this error:

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

This is the JS code I'm using :

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

I got the java code from here & added the permission:

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

And added the plugin to Plugins.xml.

Do you know what's the problem ?


回答1:


Depending on what version of PhoneGap you are using you may just have to go into the smsplugin.js and replace the instances of "PhoneGap" with "cordova".



来源:https://stackoverflow.com/questions/10397210/sendsms-plugin-not-working-on-phonegap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!