how to get ionic4 app version code example

Example 1: ionic get current app version

import { AppVersion } from '@ionic-native/app-version';
export class appVersion {
   public version;

   constructor(private appVersion: AppVersion) { 
    this.platform.ready().then(()=> {
       this.appVersion.getVersionNumber().then((res)=>{
        console.log(res); 
       }, (err)=>{
        console.log(err); 
       });
    }); 
   }
}

Example 2: how to check app version in ionic

import { AppVersion } from '@ionic-native/app-version/ngx';

constructor(private appVersion: AppVersion) { }

...


this.appVersion.getAppName();
this.appVersion.getPackageName();
this.appVersion.getVersionCode();
this.appVersion.getVersionNumber();