diff --git a/src/index.js b/src/index.js index 57a922fde..ba994e26e 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,18 @@ let wrappedPlugins = {} let promised; +function newPluginClass(config) { + let obj = { + installed: () => { + return config.pluginRef && window.hasOwnProperty(config.pluginRef); + } + } + + obj.pluginCheck = config.pluginCheck || function() { return false; }; + + return obj; +} + // Go through each registered plugin for(let plugin of PluginConfig) { console.log('Plugin', plugin.className, plugin); @@ -24,18 +36,6 @@ for(let plugin of PluginConfig) { wrappedPlugins[plugin.className] = cls; } -function newPluginClass(config) { - let obj = { - installed: () => { - return obj.pluginCheck(); - } - } - - obj.pluginCheck = config.pluginCheck || function() { return false; }; - - return obj; -} - export {wrappedPlugins}; window.Native = wrappedPlugins; diff --git a/src/plugin-config.js b/src/plugin-config.js index c4c4163c2..3351ed8f4 100644 --- a/src/plugin-config.js +++ b/src/plugin-config.js @@ -4,16 +4,12 @@ export var PluginConfig = [ className: 'Camera', plugin: 'cordova-plugin-camera', promise: ['takePicture'], - pluginCheck: () => { - return !!navigator.camera; - } + pluginRef: 'navigator.camera' }, { id: 'device', className: 'Device', plugin: 'cordova-plugin-device', - pluginCheck: () => { - return !!window.device; - } + pluginRef: 'device' } ]