- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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 kopiert
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
@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?
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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?
- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite