Ionic2 RC4 AppVersion error

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


I got an error while running “ionic serve”:

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 => { }); });

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

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

Oh right. Sorry. You need to do this:
if('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.

I works! Thank you very much~~