Hi All,
Today we are going to discuss, how we can find application version in Ionic Framework App.
Let's start by creating new Ionic Framework project with Android and iOS platform.
To create a new Project follow below command:
ionic start demoProject blank
cd demoProject
ionic platform add android
ionic platform add ios
After creating Ionic Framework project with Android and iOS platform. Now we install Apache Cordova plugin to know the version of application.
cordova plugin add https://github.com/whiteoctober/cordova-plugin-app-version.git
Now open your app.js file and write something like below code.
var example = angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
cordova.getAppVersion(function(version) {
appVersion = version;
});
});
});
Note:This code only works in $ionicPlatform.ready() or onDeviceReady() methods and gives correct results.
If we use it before $ionicPlatform.ready() it will give error or inaccurate result.
This plugin only work on Device and Simulator it is not working on web browsers.
0 Comment(s)