Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Cordova/PhoneGap plugin for accessing the native app's version and build number

- iOS
- Android
- Windows

## Installation

Expand All @@ -23,9 +24,14 @@ npm install -g cordova

## Usage

After `deviceReady` has fired you'll be able to access a new object in the global scope that contains both the app version and build number.
After `deviceReady` has fired you'll be able to access a new object in the global scope that contains three version-related properties:

- *version*: string value of the released version number
- *build*: number value of the build (more useful for Android)
- *buildString*: string value of the build (more useful for iOS, although also passes the Android build back as a string)

```javascript
console.log(AppVersion.version); // e.g. "1.2.3"
console.log(AppVersion.build); // e.g. 1234
console.log(AppVersion.buildString); // e.g. "1.2.3b4"
```
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "cordova-plugin-appversion",
"version": "1.0.0",
"version": "1.0.1",
"description": "Access the native app version & build number in JavaScript",
"cordova": {
"id": "cordova-plugin-appversion",
"platforms": [
"android",
"ios"
"ios",
"windows"
]
},
"repository": {
Expand Down
8 changes: 7 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-appversion" version="1.0.0">
id="cordova-plugin-appversion" version="1.0.1">
<name>App Version</name>
<description>Expose the native app version to JavaScript</description>
<license>MIT</license>
Expand All @@ -26,4 +26,10 @@
</config-file>
<source-file src="src/android/RareloopAppVersion.java" target-dir="src/com/rareloop/cordova/appversion" />
</platform>

<platform name="windows">
<js-module src="src/windows/RareloopAppVersion.js" name="RareloopAppVersionProxy">
<merges target="" />
</js-module>
</platform>
</plugin>
41 changes: 41 additions & 0 deletions src/windows/RareloopAppVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (c) 2015 Rareloop Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

module.exports = {

getAppVersion: function( successCallback, errorCallback ) {
try {
var pV = Windows.ApplicationModel.Package.current.id.version;
var r = {
"build": pV.build,
"version": pV.major + "." + pV.minor + "." + pV.revision
};
successCallback( r );
}
catch ( ex ) {
errorCallback( ex );
}

return true;
}
};
require( "cordova/exec/proxy" ).add( "RareloopAppVersion", module.exports );
1 change: 1 addition & 0 deletions www/app-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var RareloopAppVersion = function () {

_this.version = info.version;
_this.build = parseInt(info.build, 10);
_this.buildString = info.build;

channel.onCordovaAppVersionReady.fire();
},function(e) {
Expand Down