Checking Internet connection


#1

Iam developing an App, and i need to detect, of there is internet connection avalaible or not. Iam using network information plugin, the problem is, it says online when i connect to wifi, and dont test, if i have internet connection through this wifi. Is there any way to check if there is really internet connection?


#2

Try to use Network.type to get connectivity of your app. Since when device has no connection Netwok.type will give none, otherwise the type of network.

I use it like this:
checkNetwork() {
return new Promise((resolve,reject) =>{
if(Network.type!=‘none’){
resolve(true)
} else{
reject(false);
this.provider.toastMessage(‘Please check your connection …’)
}
})
}


#3

the problem is the network.type is wifi, but the wifi isnt connected to the internet. How to solve this problem?


#4

I don’t think this is possible as phrased here, because “the internet” is too vague. You can try reaching a specific known host.


#5

But how to check It? I mean for example if I want to check connection to specific website with specific port how is it possible? like my Oracle Apex backend which is only accessible with 8081 port number.

Thanks


#6

Establish a /heartbeat endpoint or something in your backend that just always returns 200 OK.

this._http.get('/heartbeat').subscribe(() => {
    // yep, good to go
  }, (err) => {
    // ruh roh
  });

Cannot access current network state. Type is always 'null'
#7

I solved my problem temporary, Thank you. but this make app in real world bad I used interval with this code to check real time internet connectivity.


#8

I’m having the same issue with 1.3.2 on iOS only, Android is fine. I see the endpoint and delay workarounds, but how do we contact the wrapper developer to raise an issue to get this fixed properly?