How to use a Cordova plugin?

Asked

Viewed 569 times

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);

  • Can you specify which platform you’re using (Ordova, phonegap or phonegap build)? How are you compiling your application?

  • Cordova | compile using the command : cordova build android

  • 1

    Before compiling, if you haven’t already, try the following commands: "Cordova Platform remove android" and "Cordova Platform add android".

  • I managed to uninstall the plugin I did what you said and installed the plugin again.

1 answer

1


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

cordova platform remove android
cordova platform add android

Before compiling the code:

cordova build android

I believe we can see a similar response in:

https://stackoverflow.com/questions/27538047/phonegap-build-doesnt-update-the-app

Browser other questions tagged

You are not signed in. Login or sign up in order to post.