iPhone : Running services in the background

烂漫一生 提交于 2019-12-03 21:31:59

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.

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.

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