How to get simply app version?


#1

how to get app version ?
install native plugin getting back error in ionic/native


#2

You can store the App version in a separate JSON file in your assets folder.

{ "version": "1.0.0" }

Thats it :slight_smile:


#3

You need to provide more information about what you have tried and not tried and what version of ionic native you are using.

Also providing the actual error message would help.

Are you talking about setting the version number or reading it out ?

To read it out, mine works using the latest version of ionic native.

I imported like so
import { AppVersion } from ‘@ionic-native/app-version’;

In my constructor I injected the dependency
constructor(private appVersion: AppVersion)

Then I got the app version like this

this.appVersion.getVersionNumber().then(version => {
this.versionNumber = version;
});

I also had to add appversion to my providers in my app.module.ts


#4

please give me a full example…

i gave verion:1.1.1 in config.xml but couldn’t get the version in login form… what to do?


#5

i’m also do this. but error in native/core


#6

What version of ionic are you use and what is the exact error message


#7

this.appVersion.getVersionNumber().then(version => {
this.versionNumber = version;
});

i’m using this code. but when i run my app getting error … it said runtime error
native/core


#8

With my method ou have to access the JSON file with an HTTP get request.

http.get('assets/appversioon.json')...

If you want to use the native plugin, you can test it only on your device and not in your browser. This is your mistake.


#9
<?xml version='1.0' encoding='utf-8'?>

widget id=“com.ionicframework.eattendance” version=“1.1.0” xmlns=“http://www.w3.org/ns/widgets” xmlns:cdv=“http://cordova.apache.org/ns/1.0”>
Employee Attendance
Employee Attendance Application

how to get this version. it’s under the folder is www/config.xml


#10

Runtime Error
Cannot find module “@ionic-native/core”

i’m using constructor(private appVersion: AppVersion) getting above error

Runtime Error
Cannot find module "@ionic-native/core"
Stack
Error: Cannot find module "@ionic-native/core"
at Object. (http://localhost:8100/build/main.js:114239:7)
at webpack_require (http://localhost:8100/build/main.js:20:30)
at Object. (http://localhost:8100/build/main.js:26686:84)
at webpack_require (http://localhost:8100/build/main.js:20:30)
at Object. (http://localhost:8100/build/main.js:103748:77)
at webpack_require (http://localhost:8100/build/main.js:20:30)
at Object. (http://localhost:8100/build/main.js:92442:73)
at webpack_require (http://localhost:8100/build/main.js:20:30)
at Object. (http://localhost:8100/build/main.js:114227:70)
at webpack_require (http://localhost:8100/build/main.js:20:30)
Ionic Framework: 2.1.0
Ionic Native: ^2.4.1
Ionic App Scripts: 1.1.3
Angular Core: 2.2.1
Angular Compiler CLI: 2.2.1
Node: 6.9.1
OS Platform: Windows 10
Navigator Platform: Win32
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)


#11

You still haven’t told us what version of ionic you are using. Type ionic info in and post the results.


#12

This says you are using Ionic Native 2.x.

But this module is part of Ionic Native 3.x.

Please post your package.json.

You will probably want to remove everything that has to do with Ionic Native and then follow these instructions:

https://ionicframework.com/docs/native/ (all of them, also at the bottom!)
https://ionicframework.com/docs/native/app-version/


#13

PS D:\Arul MaNo\Ionic2\EAttendanceApp> ionic info

Your system information:

ordova CLI: 6.5.0
Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.12
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.36
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.9.1
Xcode version: Not installed


#14
{
  "name": "ionic-hello-world",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.0.0",
    "@angular/compiler": "4.0.0",
    "@angular/compiler-cli": "4.0.0",
    "@angular/core": "4.0.0",
    "@angular/forms": "4.0.0",
    "@angular/http": "4.0.0",
    "@angular/platform-browser": "4.0.0",
    "@angular/platform-browser-dynamic": "4.0.0",
    "@ionic-native/background-geolocation": "^3.5.0",
    "@ionic-native/core": "3.4.2",
    "@ionic-native/geolocation": "^3.5.0",
    "@ionic-native/splash-screen": "3.4.2",
    "@ionic-native/sqlite": "^3.5.0",
    "@ionic-native/status-bar": "3.4.2",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.0.1",
    "ionicons": "3.0.0",
    "rxjs": "5.1.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.0",
    "typescript": "~2.2.1"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-statusbar",
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "description": "EAttendanceApp: An Ionic project"
}

how to update my ionic native 2.x to 2.4.1


#15

According to this package.json there is no need for this any more, this looks good. Now only follow the two links I posted to install the plugin needed to output the app version.


#16

For ionic2/3
Check here

https://learnionic2.com/2017/04/04/getting-app-version-ionic-2-application/


#17

Are you incrementing appversion.json, via a script? Could you please share the script.
and how you include the script into every “ionic cordova build …” process?
Thank you.