cordova-sms-plugin不要求许可

问题描述 投票:0回答:1

如果我添加这个,我想我有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'我有应用程序告诉我用户拒绝许可。文档中有关于询问permssion的内容,但是当我添加它时它不起作用。

我在哪里或如何获得许可?

cordova cordova-plugins
1个回答
-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
        }
© www.soinside.com 2019 - 2024. All rights reserved.