How to determine if iPhone / Android wakes up from sleep using javascript

Creating a website / webapp using sockets.io

Currently, if the user uses safari on the iphone, for example, and locks the screen (goes black). My socket connection is closed. This is good, I want this.

However, when they unlock the screen (or wake up from sleep). I would like to detect this event using javascript so that I can reconnect my socket.

Is it possible? Google doesn't really care about the topic.

+7
source share
1 answer

Nevermind, I figured it out

<script> window.addEventListener("pageshow", function(){ alert("page shown"); }, false); </script> 
+9
source

All Articles