Cordova plugin not working


#1

Hello,

I am relative new to Meteor. I want to use this Cordova plugin:

I already installed it using the CLI. Now I use this code, but nothing happens in the emulators:

if(Meteor.isCordova) {

Meteor.startup(function () {

	function onFail(message) {
	    alert('Failed because: ' + message);
	}
	
	function onSuccess2(text) {
		alert(text);
	}

	// value should be float in range from 0 to 1.
	cordova.plugins.brightness.setBrightness(0.5, onSuccess2, onFail);
	
	alert("Setted!");
});
}

What am I doing wrong?

Thanks.


#2

Try it on a device, this might be something which only works on a device.

edit: You do see the debugging “Setted!” right?


#3

When I test it on a device using:

meteor run android-device

it also doesn’t work. I do see the “Setted” alert.


#4

You might try building an APK and then do adb install [your apk] to your device. I’ve noticed differences in the past. Also, it sometimes pay to run rm -rf .meteor/local/cordova-build to clear out all the old code and start fresh. Think of it like clean.


#5

Put a console log between every step to see all gets called. And then only way is to test on a real device.


#6

Thanks, it turns out the plugin had errors. I have it working now.


#7

@eelcol great to hear that!