Page 1 of 1

How to fix the permanent blank screen on ionic app load with no internet connection?

Posted: Sun Jan 08, 2017 1:04 am
by Matt6607699

Ionic apps that are launched without an internet connection will result in a permanent blank screen after the launch image. The whole app has to be restarted after a network connection is established. There is a handler for this using the following code in the app.js file:
https://www.thepolyglotdeveloper.com/...
code
var myApp = angular.module('myapp', ['ionic'])
.run(function($ionicPlatform, $ionicPopup) {
$ionicPlatform.ready(function() {
if(window.Connection) {
if(navigator.connection.type == Connection.NONE) {
$ionicPopup.confirm({
title: "Internet Disconnected",
content: "The internet is disconnected on your device."
})
.then(function(result) {
if(!result) {
ionic.Platform.exitApp();
}
});
}
}
});
});
/code
It seems that I need to add that to the following section of my app.js file. I've tried as many ways as I can but can't figure out how/where exactly to add it?

code
var APP = angular.module(window.__APPLICATION_NAME, ['ApperyioModule', "ionic", "uiGmapgoogle-maps"]).config(["$routeProvider", '$controllerProvider', '$provide', '$locationProvider', '$compileProvider', '$filterProvider', 'uiGmapGoogleMapApiProvider', Configuration]).run(["Apperyio", "User", "$location", "$ionicPlatform", RUN]);
/code
Image

Is there a way that we can implement this so that our ionic apps don't just freeze after the launch screen when there is no internet connection? Thank you


How to fix the permanent blank screen on ionic app load with no internet connection?

Posted: Mon Jan 09, 2017 5:40 pm
by Galyna Abramovych

Hello Matt,

You need to create an Angular module (find the instructions here:
https://docs.appery.io/docs/appbuilde...) and add your code to it.
Please make sure the module name corresponds with the js file name for correct connection.