iPhone 在后台保持 websocket 打开
acani 使用 zimt websocket 进行聊天。我们能否做到当用户合上手机并将其放入口袋时,他仍然可以从 Node.js 服务器接收聊天消息并向其发送位置更新?我认为这比推送通知更好。不是吗?如果不是,为什么我们应该使用推送通知来代替或同时使用?
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非您注册了 voip/GPS/在后台播放音乐,否则您无法保持网络套接字打开。
如果您注册了这些,然后不这样做,苹果通常会拒绝该应用程序。
您无法保持网络套接字打开的原因是,如果您的应用程序在收到连接时没有跳转到前台,它就无法响应网络流量(因为如果它不在前台,则其内存内容将被冻结)。
背景网络流量会消耗电池,因为手机中的无线电是最耗能的部件之一。
通过推送通知,苹果可以管理发送通知的频率,因此您不必让手机上的所有应用程序每 2 分钟轮询一次网络,从而耗尽电池电量,您只有一个活动的网络连接,而且是间歇性的。
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.