javascript - Detect Internet-Loss in Cordova app -
in cordova-app running on android 5 device need know if device goes offline. doing according cordova-documentation:
document.addeventlistener("offline", onoffline, false); function onoffline() { // handle offline event }
for testing code, have connected android device (which doesn't has mobile-data-connection) wifi-access-point, connected internet.
as shutdown wifi-access-point event "offline" gets fired, , application knows it. far good.
unfortunately there use case in code-sample doesn't work:
image same situation: android-device connected wifi-access point, connected internet.
if disconnect wifi-access point (pull lan-cable), leave hotsport running, cordova application never know it. user can't internet related things anymore (because there no internet obviously), "offline" event never gets fired!
is there workarround this? how can check if device lost internet-connection, if there still active wifi-connection?
the plugin you're using not useful in specific case. anyway when tell "the user can't internet related things anymore" means? if there no internet, should receive "internet unavailable" answers apis , check errors in ajax calls, if use them. checking connection state, can decide do
Comments
Post a Comment