最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

sockets - How to detect iPhoneAndroid awake from sleep with javascript - Stack Overflow

programmeradmin4浏览0评论

Im building a website/webapp that uses sockets.io

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

However when they unlock the screen (or awake from sleep). I would like to detect this event with javascript so I can reconnect my socket.

Is this possible?? Google isn't turning much up on the subject.

Im building a website/webapp that uses sockets.io

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

However when they unlock the screen (or awake from sleep). I would like to detect this event with javascript so I can reconnect my socket.

Is this possible?? Google isn't turning much up on the subject.

Share Improve this question asked Feb 19, 2012 at 6:51 jennasjennas 2,4542 gold badges25 silver badges32 bronze badges 1
  • 1 What kind of solution did you end up with? – hakunin Commented Oct 23, 2015 at 9:36
Add a ment  | 

1 Answer 1

Reset to default 11

Nevermind, I figured it out

<script>
window.addEventListener("pageshow", function(){
    alert("page shown");
}, false);
</script>
发布评论

评论列表(0)

  1. 暂无评论