Reputation: 23
I'm having some issues with the new version of the cordova.js (2.6.0). It seems like the methods exec
doesn't exist anymore.
var PhoneNumberPlugin = {
callNativeFunction: function (success, fail, resultType) {
return cordova.exec( success, fail,
"com.phonenumber",
"nativeAction", [resultType]);
}
};
ERROR: 04-18 14:47:20.039: E/Web Console(6623): Uncaught TypeError: Cannot call method 'exec' of undefined at file:///android_asset/www/PhoneNumberPlugin.js:4
How could I call native plugins now? I also saw the method callbackFromNative
! Anyone knows if this one can help me out?!
Upvotes: 0
Views: 3720
Reputation: 5376
Is that the full code for your plugin? Please see https://github.com/phonegap/phonegap-plugins/wiki/Defining-Your-Cordova-Plugin-As-A-Cordova-Module I think that this should help.
Also, are you sure that you are waiting for Cordova to be fully loaded into the page? eg, wait until onDeviceReady fires.
Upvotes: 3
Reputation: 861
Your problem is that cordova is not defined. Make sure your cordova.js is actually being loaded and that it's loaded prior to this plugin you are creating.
Upvotes: 0