Reputation: 5075
I am using app-version plugin to get version number. I am trying as below : plugin
this.appVersion.getVersionNumber().then((res)=>{
console.log(res);
}, (err)=>{
console.log(err);
});
I am getting error :
class not found
does anyone faced same issue or is there any other way to get version number ?
Upvotes: 1
Views: 5090
Reputation: 877
if you use capacitor import
import {App} from "@capacitor/app";
this.platform.ready().then(async () => {
const info = await App.getInfo();
console.log(info.version)
});
Upvotes: 0
Reputation: 5075
I was forget to add in device ready event. So finally I added in device event now it is working perfectly in android and ios.
this.platform.ready().then(()=> {
this.appVersion.getVersionNumber().then((res)=>{
console.log(res);
}, (err)=>{
console.log(err);
});
});
Upvotes: 4
Reputation: 1
import { AppVersion } from '@ionic-native/app-version';
export class appVersion {
public version;
constructor(private appVersion: AppVersion) {
.
.
this.version = this.appVersion.getVersionNumber();
}
}
Using getVersionNumber function you can get the version.
Note: The App version plugin does not work on browser environments.
Upvotes: -1