ciossi
ciossi

Reputation: 143

cordova-plugin-network-information on android return connection.type = NONE even if there is 4G connection

There is a problem with Cordova-plugin-network-information on Android. Even if there is a 4G connection, sometimes, when I resume the app from the background and I check connection with navigator.connection.type it returns connection.type = NONE, but there is an internet connection. If I close and re-open the app it returns connection.type = 4G. I user [email protected] and [email protected]

Upvotes: 2

Views: 1374

Answers (2)

DaveAlden
DaveAlden

Reputation: 30366

This is the workaround I'm currently using for this issue:

document.addEventListener("resume", function(){
    navigator.connection.getInfo(function(type){
        navigator.connection.type = type;
    });
}, false);

See CB-14132 for an explanation of why.

Upvotes: 3

Younes Zaidi
Younes Zaidi

Reputation: 1190

Try to use

document.addEventListener("deviceready", onDeviceReady, false);
        function onDeviceReady() {
             if(navigator.onLine) {
                 alert("Internet Connect");
                  }else {
                       alert("No Internet");
                  }
        }

Upvotes: 0

Related Questions