Matt6607699
Posts: 0
Joined: Sat Jan 25, 2014 7:18 am

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

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

Galyna Abramovych
Site Admin
Posts: 84
Joined: Tue Mar 22, 2016 6:03 pm

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

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.

Return to “Issues”