How to use a Cordova plugin?

2

How to use plugins in Cordova? Cordova plugin background mode

I already installed with the command

cordova plugin add https://github.com/katzer/cordova-plugin-background-mode.git' porém ao tentar usar usando 'cordova.plugins.backgroundMode.enable()' e 'cordova.plugins.backgroundMode.onactivate = function() { ..algo.. };

Nothing happens.

var app = {
	link  : "http://images.terra.com/2015/05/20/corinthians.png",
	sCLoad: document.getElementById("corinthians"),
	ativo : false,
	loop  : null,
	rodarApp : function () {
		var self = this;
		this.loop = setInterval(function(){
			if (self.ativo)
				self.sCLoad.src = self.link;
		}, 1000);
	},
	ativarDesativar : function () {
		this.ativo = this.ativo ? false : true;
	}
};
document.addEventListener("deviceready", app.rodarApp,  false);
    
asked by anonymous 31.10.2015 / 00:49

1 answer

1

This problem is common, I also came across it when I started using the cordova / phonegap to make sure that the installed plugin updates take effect, we should introduce:

cordova platform remove android
cordova platform add android

Before compiling the code:

cordova build android

I think we can see a similar answer in:

link

    
31.10.2015 / 19:52