Prabhu Ganapathy
Prabhu Ganapathy

Reputation: 167

How to read version number (config.xml file) from ios phonegap App?

i want to check version update through my IOS Phonegap App. Is there any possible way to get current App version code. please help me to read this version code from config.xml file.

Upvotes: 6

Views: 4175

Answers (3)

andrew
andrew

Reputation: 2879

I'm late to the party, but I wasn't satisfied with any of the answers/plugins (I wanted to do this without a plugin). If Cordova has a way to get the version via the cordova.* api, then I haven't seen that documentation anywhere, so I came up with another method.

Before building the app, I auto-generate the file www/version.js and include it in my app's index.html:

cat config.xml \
    | grep '^<widget' \
    | sed -E 's|^.*version="([^"]+)".*|var cordova_app_version = "\1";|' \
    > www/version.js

You can then access your app's version via the global variable cordova_app_version.

Note that I do this in my project's Makefile, which controls all the building/running so this step is automated each time I do a build. Obviously you'll need a make/bash setup with cat/grep/sed.

Upvotes: 6

Arun
Arun

Reputation: 57

you can use navigator plugin to get the version number, the version number in config.xml gets added to your manifest/plist.

navigator.appInfo.getVersion();

Upvotes: 1

DaveAlden
DaveAlden

Reputation: 30366

If you use the version number in the project .plist (you'll have to increment this anyway in order to upload new versions of the app to iTunes Connect), you can read this version number easily using this Phonegap plugin by calling window.wizUtils.getBundleVersion()

Upvotes: 0

Related Questions