Using ngCordova with Ionic to check network connection DURING splashscreen

I love the ionic framework and it has been really helpful in helping my team and I create a killer app.

With that, I was debugging on android and looking for a way to check network connection DURING the splashscreen that the app starts with. So that if a user doesn’t have a network connection, the app will close. And if the user does have a network connection, the splash screen will close and go into the app.

Here were the links I was looking at, but they don’t help my specific problem:

I’ve seen references to navigator.splashscreen.hide() in my research but it doesn’t seem to be working. I’m using Xoilac TV - Website Trực Tiếp Bóng Đá Số 1 VN XoilacTV for the network check and it is working, but I don’t know how to implement control over the splashscreen. Anyone have ideas? Any help would be much appreciated.

Here is my current conditional statement:

if($cordovaNetwork.getNetwork() == 'none'){
    $ionicPopup.confirm({
       title: "Can't Find Network",
       content: "Looks like you are not connected to a network right now. Try retrying your connection."
}).then(function(result) {
    ionic.Platform.exitApp();
});
} else if($cordovaNetwork.getNetwork() == 'unknown') {
    $ionicPopup.confirm({
       title: "Unknown Network",
       content: "Looks like you are not connected to a unsupported network.    Try connecting to a different source."
}).then(function(result) {
    ionic.Platform.exitApp();
});
} else {
    navigator.splashscreen.hide();
}

Any help would be appreciated. Thanks!

1 Like

Can I get some help on this one please?

Change value in the xml file, value = “none”

value where? which attribute in xml?

<preference name="SplashScreen" value="screen"/>, this