打开设置插件 cordova

openSettings plugin cordova

我在我的项目中使用以下命令通过 node.js 安装了插件 OpenSettings

cordova plugin add https://github.com/erikhuisman/cordova-plugin-opensettings.git

但是当我使用方法时 OpenSettings.setting() logcat return 我出错了:

OpenSettings.settings error at file:///android_asset/www/plugins/nl.tapme.cordova.opensettings/www/OpenSettings.js:23

这是OpenSettings.js:

cordova.define("nl.tapme.cordova.opensettings.OpenSettings", function(require, exports, module) { module.exports = OpenSettings = {};

OpenSettings.settings = function(app, callback) {
    cordova.exec(
        // Success callback
        callback,
        // Failure callback
        function(err) { console.log('OpenSettins.settings error'); },
        // Native Class Name
        "OpenSettings",
        // Name of method in native class.
        "settings",
        // array of args to pass to method.
        []
    );
};

OpenSettings.bluetooth = function (app, callback) {
    cordova.exec(
        // Success callback
        callback,
        // Failure callback
        function(err) { console.log('OpenSettings.bluetooth error'); },
        // Native Class Name
        "OpenSettings",
        // Name of method in native class.
        "bluetooth",
        // array of args to pass to method.
        []
    );
};

OpenSettings.bluetoothStatus = function (app, callback) {
    cordova.exec(
        // Success callback
        callback,
        // Failure callback
        function(err) { console.log('OpenSettins.bluetoothStatus error'); },
        // Native Class Name
        "OpenSettings",
        // Name of method in native class.
        "bluetoothStatus",
        // array of args to pass to method.
        []
    );
};

OpenSettings.bluetoothChange = function (callback) {
    cordova.exec(
        // Success callback
        callback,
        // Failure callback
        function(err) { console.log('OpenSettins.bluetoothChange error'); },
        // Native Class Name
        "OpenSettings",
        // Name of method in native class.
        "bluetoothChange",
        // array of args to pass to method.
        []
    );
};

return OpenSettings;

});

谁能帮帮我?

我建议你测试这个插件 -> https://github.com/selahssea/Cordova-open-native-settings 你发布的第一个插件对我来说也不起作用。

这样安装:

cordova plugin add https://github.com/selahssea/Cordova-open-native-settings.git

并像这样使用它:

cordova.plugins.settings.open(settingsSuccess,settingsFail);

完整片段

function settingsSuccess() {
    console.log('settings opened');
}

function settingsFail() {
    console.log('open settings failed');
}

function openSettingsNow() {
    cordova.plugins.settings.open(settingsSuccess,settingsFail);
}

插件将打开此概览: