user796446
user796446

Reputation:

Is there a Meteor equivalent to cordova.exec?

I am looking at this Stack Overflow question

I am working on a project using Meteor. It also uses the Canvas2ImagePlugin which is a Cordova plugin.

I have successfully added it to the project using meteor add cordova:https://github.com/devgeeks/[email protected]

However, the code snippet

           cordova.exec(
            success,
            error,
            'Canvas2ImagePlugin',
            'saveImageDataToLibrary',
            [imageData]
        );

fails in Meteor since Cordova doesn't exist.

How to make this call in a Meteor way or otherwise expose Cordova to Meteor project?

Upvotes: 0

Views: 157

Answers (2)

alanionita
alanionita

Reputation: 1443

Within Meteor you'll need to use cordova from the global object since Meteor will inject the cordova object.

// First lets check that we are running withing Cordova
if (Meteor.isCordova) {

    // define your success and fail functions here
    function success() {
       // Do something
       console.log('Success')
    }

    function fail() {
       // Do something
       console.log('fail')
    }

    // Execute the cordova plugin method
    cordova.exec(success, fail, 'PluginName', 'pluginMethod', pluginMethodArguments)

}

Upvotes: 1

user3078524
user3078524

Reputation: 55

var exec = require('cordova/exec');

Upvotes: 0

Related Questions