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
Post a Comment