From f9a4ecfb5738f1774aeada2b82ceba5eec6057f5 Mon Sep 17 00:00:00 2001 From: Jonathan Herr Date: Thu, 2 Jun 2016 13:48:42 -0700 Subject: [PATCH 1/3] Add support for Windows store apps --- README.md | 1 + package.json | 5 ++-- plugin.xml | 8 +++++- src/windows/RareloopAppVersion.js | 41 +++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 src/windows/RareloopAppVersion.js diff --git a/README.md b/README.md index 9174f1e..9aa7daf 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Cordova/PhoneGap plugin for accessing the native app's version and build number - iOS - Android +- Windows ## Installation diff --git a/package.json b/package.json index 3cd18ff..2b11fea 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/plugin.xml b/plugin.xml index be914fb..6650bc3 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,6 +1,6 @@ + id="cordova-plugin-appversion" version="1.0.1"> App Version Expose the native app version to JavaScript MIT @@ -26,4 +26,10 @@ + + + + + + \ No newline at end of file diff --git a/src/windows/RareloopAppVersion.js b/src/windows/RareloopAppVersion.js new file mode 100644 index 0000000..d33ca2d --- /dev/null +++ b/src/windows/RareloopAppVersion.js @@ -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 ); \ No newline at end of file From 6482dc186055d5510dd8ee458e547e74fabdc845 Mon Sep 17 00:00:00 2001 From: eb1 Date: Fri, 6 Apr 2018 15:46:39 -0500 Subject: [PATCH 2/3] Add string version of build --- www/app-version.js | 1 + 1 file changed, 1 insertion(+) diff --git a/www/app-version.js b/www/app-version.js index f416c82..8846da3 100644 --- a/www/app-version.js +++ b/www/app-version.js @@ -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) { From 30037c8aca1da435e9a399b4295a97d3878cea73 Mon Sep 17 00:00:00 2001 From: Erik Brommers Date: Mon, 9 Apr 2018 10:06:25 -0500 Subject: [PATCH 3/3] Update README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9aa7daf..6c4aa1d 100644 --- a/README.md +++ b/README.md @@ -24,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" ```