ionic - navigator.online works in desktop but always returns true in my android phone -


i need check if user connected internet. code works on browser fails in android phone.

in app.js, have following code:

  $rootscope.online = navigator.online;       $window.addeventlistener("offline", function () {         console.log("called offline")         $rootscope.$apply(function() {           $rootscope.online = false;          });       }, false);       $window.addeventlistener("online", function () {         console.log("called online")         $rootscope.$apply(function() {           $rootscope.online = true;         });       }, false); 

in app, events never fired , navigator.online returns true? how fix this?


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -