sampart / cordova-plugin-app-version

Cordova plugin to return the version number of the current app [not maintained]
MIT License
401 stars 196 forks source link

Can't get it working on Ionic 4 (browser platform). #114

Closed leabdalla closed 5 years ago

leabdalla commented 5 years ago

I've installed like docs says:

ionic cordova plugin add cordova-plugin-app-version
npm install @ionic-native/app-version

Then added in my page.ts file:

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

...

public appVersionText:any;

...

constructor(
            private modalController:ModalController,
            public platform: Platform,
            private appVersion: AppVersion,
) {
  this.initializeApp();
}

initializeApp() {
  this.platform.ready().then(() => {

    this.appVersion.getVersionNumber().then((s) => {
      this.appVersionText = s;
    });

  });
}

And in my page.html file:

<p>{{ this.appVersionText }}</p>

So when I open my page, it shows this error in browser console:

core.js:15724 ERROR Error: Uncaught (in promise): Missing Command Error
    at resolvePromise (zone.js:831)
    at resolvePromise (zone.js:788)
    at zone.js:892
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:17290)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at drainMicroTaskQueue (zone.js:601)

Am I doing something wrong?

leabdalla commented 5 years ago

Found two errors:

1) I've missed adding AppVersion in app.module.ts

2) I've missed that it don't work in browser platform

Issue closed.

jefferlu commented 4 years ago

I encountered the same problem, thank you for your experience.