L Bahr
L Bahr

Reputation: 2901

How to exclude plug-in that does not support browser from browser build

I am trying to use cordova-plugin-device-name, but when testing in browser I get “[ERROR] Error initializing Cordova: Missing Command Error”. In the console I get “Error: exec proxy not found for :: DeviceName :: get”. After looking at plugin.xml I can see that it has no support for the browser platform. Is there any way to exclude this plug-in from browser when I add the plug-in to my project? Currently I have Android, iOS, and browser as my supported platforms.

I am hoping to use the cordova add plugin mechanic and not plugman

Upvotes: 0

Views: 483

Answers (1)

johnborges
johnborges

Reputation: 2533

Why not use Apache's Device Plugin instead of the one you're using now. The Device Plugin supports the browser platform as well as many others.

document.addEventListener('deviceready', onDeviceReady, false);

function onDeviceReady () {
    alert(device.model);
}

If you want to continue using the cordoba-plugin-device-name then maybe look try detecting if you're on a browser and avoid using the DeviceName object.

if(device.platform === 'browser'){

}else{
    /* do stuff with DeviceName */
}

Upvotes: 1

Related Questions