Get application version from native

I have built an application with Ionic 3 but I am absolutely SHOCKED to find out how difficult / impossible / not-documented it is to get your application’s version. So if I release a version “1.0.1” I have to change strings all over in the source code (and not forget any) because there is no way to get this programmatically? I see two plugins, one unmaintained for years and the other just doesn’t work because there aren’t clear directions on how to use a cordova plugin in Ionic3. (Ok, I installed it. Now how do I import it or use it? Where is it? What is the difference between @ionic-native and ionic-native and @ionic-native/splash-screen and how would I get this import location if I didn’t know it)

I am shocked by different things…

Here is the plugin you need:
http://ionicframework.com/docs/native/app-version/

And here are additional information on installation:
http://ionicframework.com/docs/native/

Not that hard…

1 Like

I think a big part of the root cause of this is that I was using “ionic serve” instead of “ionic run browser”. Which is ignoring about 75 other things you need to do in order for that to happen. Then an only then does this work. This is super unclear in the documentation. Also, searching documentation for “publish” yields zero results. ?? What is aligning a zip? There basically is no documentation for publishing an ionic app.

I have this tutorial for Ionic 4

We can get values like

this.appVersion.getAppName().then(value => {
  this.AppName = value;
}).catch(err => {
  alert(err);
});

this.appVersion.getPackageName().then(value => {
  this.PackageName = value;
}).catch(err => {
  alert(err);
});

this.appVersion.getVersionCode().then(value => {
  this.VersionCode = value;
}).catch(err => {
  alert(err);
});

this.appVersion.getVersionNumber().then(value => {
  this.VersionNumber = value;
}).catch(err => {
  alert(err);
});

This was about version number, and not application name

hi @bgiaraffa, I have updated code here for other methods too