iPhone保持websocket在后台打开 [英] iPhone keep websocket open in background

查看:242
本文介绍了iPhone保持websocket在后台打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

acani使用 zimt websocket 进行聊天。我们可以这样做,以便当用户关闭手机并将其放入口袋时,他仍然可以从node.js服务器接收聊天消息并将位置更新发送到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?

谢谢!

推荐答案

你不能打开网络套接字,除非你注册了在后台播放的voip / GPS /音乐。

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.

通过推送通知,apple管理它们被发送的频率,因此您没有手机上的所有应用程序每隔2分钟查看一次网络查杀电池,你只有一个有效的网络连接,这是间歇性的。

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.

这篇关于iPhone保持websocket在后台打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆