n0minal
n0minal

Reputation: 3223

Create Cordova 2.2.0 Plugins

I've been wondering why my old plugins does not work in cordova 2.2.0. As I found out that there is a new structure in how to make javascript file for Plugins. I was able to make it work but I have a question.

Before I can do this.

window.plugins.pluginName.functionName(\"%@\");

Which would allow me to call functionname in from objective c to javascript.

How would that appply to the new format for 2.2.0 versions?

Upvotes: 1

Views: 458

Answers (1)

Simon MacDonald
Simon MacDonald

Reputation: 23273

The window.plugins object is no more. In your plugin's js code what you would need to do is:

if (!window.plugins) {
    window.plugins = {};
}
if (!window.plugins.pluginName) {
    window.plugins.pluginName = new pluginName();
}

and then it should act the way it used to without having to change the rest of your code.

Upvotes: 1

Related Questions