Hi there
I hope some one can help me with my problem.
I’m currently developing an app for android and ios. My problem is now, that if I run the app with ionic cordova run android --d
it builds successfully. But after the app starts, the root page gets loaded (redirect to AuthPage
) but no code gets executed inside of it. On iOS it works fine!
The really strange thing now is, this only happens on the very first “startup” after the build. When I close the app and open it again, it works just fine…
ionic info:
Ionic:
ionic (Ionic CLI) : 4.0.3
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.9
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0, ios 4.5.5
System:
ios-deploy : 1.9.2
NodeJS : v8.9.4
npm : 5.7.1
OS : macOS High Sierra
Xcode : Xcode 10.0 Build version 10A255
Now to the code:
app.component.ts:
constructor(public _plt: Platform,
...
) {
this.initializeApp();
}
initializeApp() {
this._plt.ready().then(() => {
let parameterPromise = this.referenceService.init();
let languagePromise = this.languageService.init();
// Dynamic menu
this.menuUtils._menuSubject.asObservable().subscribe(() => {
this.menuItems = this.menuUtils.getPages();
});
// Subscribe to network's onDisconnect event
this.network.onDisconnect().subscribe(() => {
//doing some stuff
});
Promise.all([parameterPromise, languagePromise]).then((values) => {
return Promise.resolve();
})
}).then(() => {
return this.nav.setRoot(AuthPage)
});
}
Now the auth page:
ngAfterViewInit() {
this._plt.ready().then(() => {
this.init();
}).catch(ex => {
console.error(ex);
});
}
init() {
...
// the code here never gets executed on initial startup after build on android"
this._storageUtils.checkDeviceSecure().then(res => {
...
});
}
I can open the source code with chrome://inspect and set a breakpoint inside the init()
function of the auth page. Like already said, on the very first startup (initial startup) after building/running the app on a device, it will never get there. After closing the app and open it again, it gets executed and the app works fine. The strangest thing is, that this happens with android only.
Anybody got similar problem or have an idea what I did wrong?