Blank page if no internet connection and app is first time opened after installing


#1

When I do a fresh install of the app to a device without internet connection and open the app, it’s showing white blank screen. It doesn’t happen if I open the app for the first time with internet connection, then I turn the connection off and reopen the app.

I am checking the network in app.component.ts after platform is ready and expected behaviour is to show an alert and exit the app.


@Component({
     templateUrl: 'app.html'
})
export class MyApp {
    public isOnline: boolean = navigator.onLine;

 ...

ngOnInit() {
    this.platform.ready().then(() => {
    this.checkNetwork()
    ...
}

checkNetwork() {
    if (!this.isOnline) {
      console.log("No internet connection!");
      // show alert & if user clicks ok:
      this.platform.exitApp();
}

XCode gives me this output:

2018-04-16 10:56:49.334609+0200 XXX[1406:913593] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/DE54ADB9-DA2F-4115-B6D4-BD088B359E95/Library/Cookies/Cookies.binarycookies
2018-04-16 10:56:49.411451+0200 XXX[1406:913593] Apache Cordova native platform version 4.5.3 is starting.
2018-04-16 10:56:49.412436+0200 XXX[1406:913593] Multi-tasking -> Device: YES, App: YES
2018-04-16 10:56:49.490257+0200 XXX[1406:913593] Using UIWebView
2018-04-16 10:56:49.493448+0200 XXX[1406:913593] [CDVTimer][console] 0.072002ms
2018-04-16 10:56:49.493603+0200 XXX[1406:913593] [CDVTimer][handleopenurl] 0.089049ms
2018-04-16 10:56:49.495622+0200 XXX[1406:913593] [CDVTimer][intentandnavigationfilter] 1.986027ms
2018-04-16 10:56:49.495736+0200 XXX[1406:913593] [CDVTimer][gesturehandler] 0.066996ms
2018-04-16 10:56:49.496526+0200 XXX[1406:913593] [CDVTimer][backgroundfetch] 0.759959ms
2018-04-16 10:56:49.532622+0200 XXX[1406:913593] [CDVTimer][file] 36.006927ms
2018-04-16 10:56:49.532960+0200 XXX[1406:913593] CDVIonicKeyboard: no resize
2018-04-16 10:56:49.534117+0200 XXX[1406:913593] CDVIonicKeyboard: WARNING!!: Keyboard plugin works better with WK
2018-04-16 10:56:49.534268+0200 XXX[1406:913593] [CDVTimer][keyboard] 1.487017ms
2018-04-16 10:56:49.541007+0200 XXX[1406:913593] [CDVTimer][localnotification] 6.672978ms
2018-04-16 10:56:49.541085+0200 XXX[1406:913593] [CDVTimer][localnotification] 0.010967ms
2018-04-16 10:56:49.564070+0200 XXX[1406:913593] [CDVTimer][splashscreen] 22.946000ms
2018-04-16 10:56:49.571091+0200 XXX[1406:913593] [CDVTimer][statusbar] 6.929040ms
2018-04-16 10:56:49.571166+0200 XXX[1406:913593] [CDVTimer][TotalPluginStartup] 79.162002ms
2018-04-16 10:56:50.271390+0200 XXX[1406:913593] Resetting plugins due to page load.
2018-04-16 10:56:50.570360+0200 XXX[1406:913653] TIC TCP Conn Failed [1:0x1c4178e40]: 1:50 Err(50)
2018-04-16 10:56:50.573337+0200 XXX[1406:913653] Task <2635004D-F7C8-4E33-A740-20B80773C58B>.<0> HTTP load failed (error code: -1009 [1:50])
2018-04-16 10:56:50.573678+0200 XXX[1406:913652] NSURLConnection finished with error - code -1009
2018-04-16 10:56:50.868918+0200 XXX[1406:913593] Finished load of: file:///var/containers/Bundle/Application/C1AD3085-EECA-495F-A5EF-E589CA7BB9F6/XXX.app/www/index.html
2018-04-16 10:56:50.975567+0200 XXX[1406:913593] Ionic Native: deviceready event fired after 137 ms

Does anyone know what might be causing this?