iPhone:在后台运行服务

发布于 2024-10-21 06:30:00 字数 178 浏览 2 评论 0原文

环顾四周,我认为唯一的后台服务类型是音频、VoIP 和位置服务,这样的想法是否正确,因此如果我想与服务器通信,我必须使用推送通知。这意味着徽章仅用于推送通知。

更新: 我想每 5 分钟左右检查一次服务器上的更新。所以设备正在检查服务器,而不是服务器推送到设备。我想电子邮件就是一个例子。它轮询服务器。

谢谢西蒙

Having a look around, am I correct in thinking that the only type of background services are audio, voip and location services and so that if I wanted to communicate with a server I have to use push notifications. This means that badges are only uses for push notifications.

Update:
I want to check for updates on the server every 5 minutes or so. So the device is checking the server, not the server pushing to the device. I suppose email is an example. It polls the server.

Thanks Simon

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

慕巷 2024-10-28 06:30:00

推送通知听起来是您最好的选择。与其让客户端每 5 分钟检查一次更新,不如让服务器告诉您的客户端何时有需要注意的更新。

这是否会惹恼您的用户取决于您推送更新的频率。 iOS 上的通知相当具有侵入性,因此请谨慎使用。

Push Notifications sounds like your best bet. Rather than have the client check for updates every 5 minutes have the server tell your client when there is an update that it should be aware of.

Whether this is going to annoy your users or not depends on how frequently you're pushing updates. Notifications on iOS are fairly intrusive so use them sparingly.

夏末 2024-10-28 06:30:00

您有多种选择:

  • 推送通知
    这对于电池和设备资源来说是最友好的;不过,需要通知系统的服务器端实现。 --- 可能不是您当前正在寻找的,但在即时通知和网络丢失处理方面绝对是“最佳”解决方案。

  • 在后台运行应用程序
    应用可以在后台运行并不断检查服务器是否有新数据等...但是,不能保证应用程序可以运行很长时间,因为iOS的进程管理器可能会将您的应用程序置于睡觉或意外退出。 --- 可能更接近您正在寻找的内容,并且可能适用于基本测试;但不太可靠。

  • 支持多任务处理
    这显然是“最好”的方法。实现对多任务处理的支持,并让 iOS 在检测到流量时唤醒您的应用程序。这可以使用“voip”后台模式来完成。

You have a number of options:

  • Push Notifications
    This is the most friendly for battery and device resources; requires a server-side implementation of the notification system, though. --- Possibly not what you are currently looking for, but definitely the "best" solution when it comes to instant notifications and network-loss handling.

  • Running the App in the background
    Apps can run in the background and keep checking a server for new data, etc... However, it is not guranteed that the application may run for a long time since iOS's process manager might put your App to sleep or quit it unexpectedly. --- Possibly comes closer to what you are looking for and might work for basic tests; but is not very reliable.

  • Supporting Multitasking
    This is obviously the "best" way to do it. Implement support for multitasking and have iOS wake up your application whenever traffic is detected. This can be done using the "voip" background-mode.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文