Calling a service every time the first page loads

Hi everybody,

I’m new to Ionic. Really it’s my first serious application.
I want my app to show the phone information in the first page everytime the application is loaded. so I have created a separate service called siminfo.service. I created getSimInfo inside the service which tries to check if the read permission is available first. if there is no permission then it tries to request the required phone permission. All of the sequencing is provided by using promise logic and then functions. Also I used ngInit function to force the app run the service each time the first (home) page is loaded.

The whole code is uploaded to:

The app works fine when I build it for android in debug mode using: ionic cordova build android. The popup appears when I open the app for the first time and requests for approperiate permission. The correct information is then shown according to answer to the permission request.

But when I build the application in production mode using “ionic cordova build android --prod” the permission popup is not shown just after opening the app and the first page is just blank. But when I select the home page from the slide menu or go to about page and come back to home page, the popup shows and the application works fine.

Please help to get it work in production mode!
Thanks a lot


try ionViewDidLoad() instead ngOnInit()

ionViewDidLoad() {
    this.platform.ready().then(() => { 
    // your init service
1 Like

This solved my problem though I cannot understand what’s the actual problem. Thank you very much.

For more information about platform:

1 Like