Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

cordova

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.

like image 624
Prabhu Ganapathy Avatar asked Sep 19 '13 09:09

Prabhu Ganapathy


People also ask

Where do I find config xml?

Each WebLogic Server domain contains a central configuration file called the config. xml, which is stored in the DOMAIN_HOME\config directory. Both the Admin Server and the Managed Servers derive their run-time configuration information from the config.

What is config xml file?

The config. xml file is a persistent store for the managed objects that WebLogic Server creates and modifies during its executing using the BEA implementation of the JMX API. The purpose of config. xml is to store changes to managed objects so that they are available when WebLogic Server is restarted.

What is config xml file in cordova?

config. xml is a global configuration file that controls many aspects of a cordova application's behavior. This platform-agnostic XML file is arranged based on the W3C's Packaged Web Apps (Widgets) specification, and extended to specify core Cordova API features, plugins, and platform-specific settings.

Where is cordova config?

The Cordova config. xml file is the global configuration file of the application. The Cordova configuration file is a mandatory XML file that contains application metadata, and is stored in the root directory of the app.


1 Answers

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.

like image 115
andrew Avatar answered Nov 15 '22 08:11

andrew