cordova-sms-plugin不要求许可

时间:2018-12-17 20:55:53

标签: cordova cordova-plugins

如果我添加此代码,我认为我可以使用cordova-sms-plugin

sendSms: function() {
        var number = document.getElementById('numberTxt').value.toString(); /* iOS: ensure number is actually a string */
        var message = document.getElementById('messageTxt').value;
        console.log("number=" + number + ", message= " + message);

        //CONFIGURATION
        var options = {
            replaceLineBreaks: false, // true to replace \n by a new line, false by default
            android: {
                intent: ''  // send SMS with the native android SMS messaging
                //intent: '' // send SMS without opening any other app
            }
        };

        var success = function () { alert('Message sent successfully'); };
        var error = function (e) { alert('Message Failed:' + e); };
        sms.send(number, message, options, success, error);
        //$window.sms.send(number, message, intent, success, error);
    }

删除“ INTENT”后,我的应用程序告诉我用户正在拒绝许可。文档中有一些关于询问权限的说法,但是当我添加时,它是行不通的。

我在哪里或如何寻求许可?

1 个答案:

答案 0 :(得分:-1)

修复后,我将其添加到了android.json

  {
          "xml": "<uses-permission android:name=\"android.permission.RECEIVE_SMS\" />",
          "count": 1
        },
        {
          "xml": "<uses-permission android:name=\"android.permission.READ_SMS\" />",
          "count": 1
        },
        {
          "xml": "<uses-permission android:name=\"android.permission.SEND_SMS\" />",
          "count": 1
        }