iPhone keep websocket open in background

﹥>﹥吖頭↗ 提交于 2020-01-01 22:01:34

问题


acani uses zimt websocket for chat. Can we make it so that when a user closes his phone and puts it in his pocket, he can still receive chat messages from and send location updates to the node.js server? I think this would be nicer than push notifications. Don't you? If not, why should we use push notifications instead or also?

Thanks!


回答1:


You can't keep a network socket open, unless you are registered for voip/GPS/music playing in the background.

if you register for these, and then don't do them, apple usually reject the app.

the reason you cant keep a network socket open, is that without your app jumping to the foreground when it receives a connection, it cannot respond to network traffic(because if it is not in the foreground its memory content is frozen).

background network traffic kills the battery, as the radios in phones are one of the most energy intensive parts.

with push notifications, apple manage how often they are sent out, so you don't have all of the applications on the phone polling the network every 2 minutes killing the battery, you only have one active network connection, which is intermittent.



来源:https://stackoverflow.com/questions/4456407/iphone-keep-websocket-open-in-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!