Handling standby on iPad using Javascript -
regarding ipad events, how determine if/when ipad changing awake state standby state?
what put mobile-safari web app in locked state whenever ipad becomes inactive/standby , ask pin when becomes awake again.
i agree there ought signal can hook on to know when application goes sleep , when wakes up, should able figure out when safari wakes indirectly.
when webview goes background, safari puts in sleep. pauses video, defers network request, stops updating ui , pauses setinterval/settimeout operations. js never aware (as far can tell) how these things happened, can tell has happened. simplest way use build regularly invoked method , check see if it's been unexpectedly long time since last update. if expect update every 10 seconds , it's been 5 minutes, can sure device has woken up. here's quick example thought up:
var inttime = new date().gettime(); var gettime = function() { var intnow = new date().gettime(); if (intnow - inttime > 1000) { console.log("i woke up") } inttime = intnow; settimeout(gettime,500); }; gettime();
this detect when user has returned tab, has dismissed developer console or brought safari background. i've set interval @ half second; set @ need, though think low values have concurrency issues , burn battery down on device unnecessarily.
Comments
Post a Comment