Nadim Iqbal
Nadim Iqbal

Reputation: 103

Ionic window.Connection is undefined

I am working with Ionic and trying to check internet connection status. But it says window.Connection is undefined. I am connected to a wifi network. How can I get the correct internet status?

I have installed this plugin

cordova plugin add org.apache.cordova.network-information

And this is my controller.

$scope.checkInternetConnection=function(){
            var con=window.Connection;
            console.log(con);
            if(window.Connection) {
                if(navigator.connection.type == Connection.NONE) {
                    console.log("No");
                }
                else{
                    console.log("Yes");
                }
            }
        }

Upvotes: 0

Views: 2221

Answers (1)

user3255670
user3255670

Reputation:

you are using an old version of the plugin. I can tell because you are using the old spelling.

You want:

cordova plugin add cordova-plugin-network-information

That plugin documentation is here.

Also, source your "core" plugins from this list. The plugins are retrieved via on NPM. Which, if you don't know you should be using NPM for your package management. So, if you do not know, read Cordova Plugins Registry becomes immutable (08 Sep 2015)

Lastly, this FAQ might help with some of the thorny issue you are going to find. I recommend you read the bold sentences and read the details as you need them.

Top Mistakes by Developers new to Cordova/Phonegap

Lastly, if you are going to use the network, you will need to understand the "whitelist" system, READ: Whitelist Guide

Upvotes: 3

Related Questions