- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a way to get the project version # (under build properties) so I can display it on my app's about page?
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is not a way to dynamically get the app version from the code. This would be something you would have to statically type in each time. My question is, why would you want to do this? When you submit to any app store, it is going to make you provide a version number. This would be visible to your users via the operating system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Hooman,
You can access the version number in your code. Version number is saved in the config.xml file. The "version" attribute in the second line of config.xml file gives you the version number.
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:intelxdk="http://xdk.intel.com/ns/v1" id="xdk.sample.helloworld" version="0.0.1" android-versionCode="1">
You can access it by loading XML document through XMLHttpRequest synchronous call, although you have to check for device type to load platform specific config.xml. For e.g. for Android, it is intelxdk.config.android.xml, for iOS it is intelxdk.config.iOS.xml etc.
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, thanks. I'll look into using the config file.
Ps: One reason besides aesthetics for an about page might be to send the version to the backend so that old clients are invalidated / stopped from accessing the backend APIs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, perfectly valid reason.
Here is a snippet that I quickly tried for Android. In actual app you have to detect the device OS and pick the xml file accordingly.
if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); xhttp.open("GET","intelxdk.config.android.xml",false); xhttp.setRequestHeader("Content-Type","text/xml"); xhttp.send(null); var xmlDoc = xhttp.responseXML; x = xmlDoc.getElementsByTagName('widget'); var vernumber = x[0].getAttribute('version'); alert(vernumber); }
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@SWATI, I am getting a null for xmlDoc. I suspect that's because the intelxdk.config.ios.xml (in my case) is outside the www folder. Is your config file inside the www folder?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Any update here? I have verified it's the issue with the config file being outside of the www folder. If I copy the file inside www, then the SWATI's code runs. Any idea how to get XDK to move these files into www or access them outside www folder?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page