iPhone:在后台运行服务 [英] iPhone : Running services in the background

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

问题描述

环顾四周,我认为唯一类型的后台服务是音频,voip和位置服务,所以如果我想与服务器通信,我必须使用推送通知。这意味着徽章仅用于推送通知。

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.

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

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.

谢谢Simon

推荐答案

你有一个选项数量:


  • 推送通知

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

  • 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.

在后台运行应用程序

应用程序可以在后台运行并继续检查服务器是否有新数据等等但是,它不是保证应用程序可能会运行很长时间,因为iOS的进程管理器可能会让您的应用程序进入睡眠状态或意外退出。 ---可能更接近您正在寻找的东西,并可能适用于基本测试;但是不太可靠。

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.

支持多任务处理

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

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.

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

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