# Ionic2 RC4 AppVersion error

**URL:** <https://forum.ionicframework.com/t/ionic2-rc4-appversion-error/73451>\
**Category:** ionic-v3\
**Created:** [December 16, 2016, 8:55am UTC](https://forum.ionicframework.com/t/ionic2-rc4-appversion-error/73451 "2016-12-16T08:55:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zapzqc](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/zapzqc/32/92962_2.png) [@zapzqc](https://forum.ionicframework.com/u/zapzqc)\
**Post date:** [December 16, 2016, 8:55am UTC](https://forum.ionicframework.com/t/ionic2-rc4-appversion-error/73451/1 "2016-12-16T08:55:21Z")

</div>

My code is:  
AppVersion.getVersionNumber().then(data =\> {

```
    });

```

I got an error while running “ionic serve”:

 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/1/3/13616bdf5a2eeb88f83141e33af77c2c3a755a4a.png)

---

<div class="post-metadata">

**Author:** ![alex\_key](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/alex_key/32/103500_2.png) [@alex\_key](https://forum.ionicframework.com/u/alex_key)\
**Post date:** [December 16, 2016, 9:18am UTC](https://forum.ionicframework.com/t/ionic2-rc4-appversion-error/73451/2 "2016-12-16T09:18:10Z")

</div>

It’s because AppVersion is a cordova only plugin, therefore it will not work on browsers. Wrap your code inside a `platform.ready().then(() => { });`

like this:

`platform.ready().then(() => { AppVersion.getVersionNumber().then(data => { }); });`

EDIT:  
Also make sure to inject platform in the constructor:  
`import {Platform} from 'ionic-angular'; ... constructor(public platform: Platform) ...`

---

<div class="post-metadata">

**Author:** ![zapzqc](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/zapzqc/32/92962_2.png) [@zapzqc](https://forum.ionicframework.com/u/zapzqc)\
**Post date:** [December 16, 2016, 9:31am UTC](https://forum.ionicframework.com/t/ionic2-rc4-appversion-error/73451/3 "2016-12-16T09:31:04Z")

</div>

My code is already inside “platform.ready()”， I also use Toast plugin， it works well.

---

<div class="post-metadata">

**Author:** ![alex\_key](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/alex_key/32/103500_2.png) [@alex\_key](https://forum.ionicframework.com/u/alex_key)\
**Post date:** [December 16, 2016, 10:24am UTC](https://forum.ionicframework.com/t/ionic2-rc4-appversion-error/73451/4 "2016-12-16T10:24:02Z")

</div>

Oh right. Sorry. You need to do this:  
`if(platform.is('cordova')) { ... }`

The problem is that the cordova interface is not ready. And the platform.ready runs on regular browsers as well. The AppVersion will not work during serve, only on devices or simulators. My bad there.

---

<div class="post-metadata">

**Author:** ![zapzqc](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/zapzqc/32/92962_2.png) [@zapzqc](https://forum.ionicframework.com/u/zapzqc)\
**Post date:** [December 19, 2016, 3:39am UTC](https://forum.ionicframework.com/t/ionic2-rc4-appversion-error/73451/6 "2016-12-19T03:39:10Z")

</div>

I works! Thank you very much~~
