$cordovaAppVersion is not working

I tried latest ng-cordova and $cordovaAppVersion is not working. undefined function getAppVersion in ng-cordova.js

I/chromium(25203): [INFO:CONSOLE(210)] "Uncaught TypeError: Object #<Object> has no method 'getAppVersion'", source: file:///android_asset/www/js/ng-cordova.js (210)

Hi, I have the same problem. Could you resolve it at the end?

In the folder “hooks/before_prepare” have you the file “setVersionOnApp.js” with this content:

#!/usr/bin/env node

var fs = require(‘fs’);
module.exports = function(context) {

var cordova_util = context.requireCordovaModule(“cordova-lib/src/cordova/util”),
ConfigParser = context.requireCordovaModule(‘cordova-lib/src/configparser/ConfigParser’),
projectRoot = cordova_util.isCordova(),
xml = cordova_util.projectConfig(projectRoot),
cfg = new ConfigParser(xml),
version = cfg.version();

fs.writeFileSync(
context.opts.plugin.dir + ‘/www/getAppVersion.js’,
‘module.exports.getAppVersion = function() { return "’ + version + ‘";};’
);
};

Plugin has changed in github repo but not updated in ngCordova.

see:

Before:

cordova.getAppVersion(...)

Now:

cordova.getAppVersion.getVersionNumber().then(function (version) {....}).

You need to change above code in your ng-cordova.js file.

Note: In case anyone comes across this thread with the same issue, there is no need to update your ng-cordova.js file. Simply replace $cordovaAppVersion.getAppVersion() with $cordovaAppVersion.getVersionNumber().

ngCordova & the App Version Plugin have been updated and the $cordovaAppVersion.getAppVersion() method has been deprecated. The equivalent method in current versions of ngCordova & the App Version Plugin is: $cordovaAppVersion.getVersionNumber().