Using ngCordova with Ionic to check network connection DURING splashscreen


#1

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 http://ngcordova.com/docs/plugins/network/ 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!


#2

Can I get some help on this one please?


#3

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


#4

value where? which attribute in xml?


#5

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