# Plugin called before platform.ready() on --prod

**URL:** <https://forum.ionicframework.com/t/plugin-called-before-platform-ready-on-prod/104496>\
**Category:** ionic-v3\
**Created:** [September 6, 2017, 3:15pm UTC](https://forum.ionicframework.com/t/plugin-called-before-platform-ready-on-prod/104496 "2017-09-06T15:15:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marquesgabriel](https://avatars.discourse-cdn.com/v4/letter/m/e8c25b/32.png) [@marquesgabriel](https://forum.ionicframework.com/u/marquesgabriel)\
**Post date:** [September 6, 2017, 3:15pm UTC](https://forum.ionicframework.com/t/plugin-called-before-platform-ready-on-prod/104496/1 "2017-09-06T15:15:51Z")

</div>

Hello,  
I’m developing an app that uses NativeStorage plugin. I’ve created a provider that has some methods that use this plugin and other classes uses this provider.  
But when i tried to create the app with `--prod` this plugin is called before platform.ready(), resulting the message on the console:

> Native: tried calling NativeStorage.getItem, but the NativeStorage plugin is not installed.  
> Install the NativeStorage plugin: ‘ionic cordova plugin add cordova-plugin-nativestorage’

How can i ensure that the provider is only called after platform.ready()?  
I’m testing on one physical and one virtual android device and both of them show the same behaviour  
Thanks

Environment info:

```auto
cli packages:

    @ionic/cli-utils : 1.6.0 (/home/zaphod/desenvolvimento/project/node_modules/ionic/node_modules/@ionic/cli-utils)
    ionic (Ionic CLI) : 3.6.0 (/home/zaphod/desenvolvimento/project/node_modules/ionic)

global packages:

    Cordova CLI : 7.0.1 

local packages:

    @ionic/app-scripts : 2.0.2
    @ionic/cli-plugin-cordova : 1.4.1
    @ionic/cli-plugin-ionic-angular : 1.3.2
    Cordova Platforms : android 6.2.3
    Ionic Framework : ionic-angular 3.5.3

System:

    Android SDK Tools : 25.2.5
    Node : v8.1.2
    OS : Linux 4.4
    npm : 5.0.3 

```

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [September 6, 2017, 4:43pm UTC](https://forum.ionicframework.com/t/plugin-called-before-platform-ready-on-prod/104496/2 "2017-09-06T16:43:08Z")

</div>

Use `platform.ready()` as it is used in app.component.ts and wrap your plugin calls. Then they will only be executed after the platform is ready.

PS: Do you really need NativeStorage? Ionic Storage provides very similar functionality and also works in `ionic serve` (and doesn’t need additional native code)

---

<div class="post-metadata">

**Author:** ![marquesgabriel](https://avatars.discourse-cdn.com/v4/letter/m/e8c25b/32.png) [@marquesgabriel](https://forum.ionicframework.com/u/marquesgabriel)\
**Post date:** [September 6, 2017, 5:11pm UTC](https://forum.ionicframework.com/t/plugin-called-before-platform-ready-on-prod/104496/3 "2017-09-06T17:11:38Z")

</div>

Hello.  
I did what you suggested and it work as expected. Thank you.  
About the Ionic Storage. I didn’t know about it but thanks for the suggestion!
