openSettings 插件科尔多瓦

Posted

技术标签:

【中文标题】openSettings 插件科尔多瓦【英文标题】:openSettings plugin cordova 【发布时间】:2015-10-13 21:32:50 【问题描述】:

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

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

但是当我使用方法OpenSettings.setting()logcat 时返回错误:

OpenSettings.settings 错误 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;

);

谁能帮帮我?

【问题讨论】:

【参考方案1】:

我建议你测试这个插件 -> 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);

完整的 sn-p

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


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


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


插件将打开此概览:

【讨论】:

我只需在需要打开设置的地方复制并粘贴 cordova.plugins.settings.open(success_callback,failure_callback) ? 因为现在 logcat 返回我“success_callback is not defined” 您是开发新手,不是吗?我要编辑我的答案。等一下。 您可以将openSettingsNow 绑定到您的按钮或链接或类似的东西。 请接受我的回答并投票 :) 我刚刚投票赞成你的问题 - 这就是它的工作原理。

以上是关于openSettings 插件科尔多瓦的主要内容,如果未能解决你的问题,请参考以下文章

用于普通科尔多瓦的科尔多瓦离子插件?

安装科尔多瓦插件时出错

如何编辑离子科尔多瓦插件

科尔多瓦推送通知插件抛出错误

科尔多瓦中的admob插件错误

科尔多瓦升级后本地通知插件损坏