Capacitor network return always true connection status.
My current versions 1 - "@angular/core": "~10.0.0" 2 - "@capacitor/ios": "^3.4.3" 3 - "@capacitor/android": "^3.4.3" 4 - "@capacitor/core": "^3.4.3" 5 - "@capacitor/network": "^1.0.7"
app.component.ts File code below
import { Network } from '@capacitor/network';
async ngOnInit() { let status; const status = await Network.getStatus(); status = status.connected; Network.addListener('networkStatusChange',(val: any) => { if(val.connected){ status = status.connected; } }); } What's thing which missed from my side? It's returning only true connected status of network even i have not connected to any network.
Any one help me.
check ConnectionType to see what is connected
@jongbonga It's giving me "cellular". But now I'm using wifi so connectionType also return wrong.
@jongbonga It's giving me "cellular". But now I'm using wifi so connectionType also return wrong.
Then status.connected is true is correct because you are connected.
Don't confuse connected to the internet with connected to a Network. Cellular & Wifi are Network which is what the plugin checks.
Try to be on airplane mode then check again, connected should be equal to false