在启动时运行后台任务 [英] Running background task on startup

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

问题描述

我正在编写一个iOS应用程序,它使用Dropbox Datastore API在多个设备之间同步数据。

I'm writing an iOS app that uses the Dropbox Datastore API to sync data across multiple devices.

在Android上,我可以告诉服务在启动时启动,这使它能够同步设备关闭时可能发生的任何更改。

On Android, I'm able to tell the service to start on boot, which enables it to sync any changes that may have occurred whilst the device was turned off.

我无法找到确定的方法让我的应用程序在iOS上也这样做。

I'm having trouble finding a definitive way to have my app do the same on iOS.

那么,是否有人有任何建议:

So, does anyone have any recommendations to:


  • 在iOS上有效且可靠地运行简单的后台服务。

  • 让服务在启动时启动

这必须是可行的 - 一旦设备完成启动,Facebook和Gmail等应用就会开始同步。

This must be possible - apps like Facebook and Gmail start syncing as soon as the device finishes booting.

推荐答案


在iOS上有效且可靠地运行简单的后台服务。

Run a simple background service efficiently and dependably on iOS.

您无法在iOS上运行后台服务。您可以在后台执行部分操作,但操作系统保留随时终止您的应用的权利。

You cannot run background services on iOS. You can perform some operations in background, but the OS reserves the right of killing your app at any time.


让服务在启动时启动

Have the service start at boot

不可能。在iOS上启动时,第三方应用程序无法自动运行。

Impossible. Third-party applications cannot run automatically at boot on iOS.


这一定是可能的 - 像Facebook和Gmail这样的应用程序会尽快开始同步设备完成启动。

This must be possible - apps like Facebook and Gmail start syncing as soon as the device finishes booting.

鉴于上述情况,我绝对可以告诉你,他们没有。它可能看起来像,但它们在技术上无法做到这一点。

Given what stated above, I definitely can tell you that they don't. It might look like, but they cannot technically do that.

iOS 7上的一个选项是让您的应用在特殊推送通知时在后台刷新数据如所讨论的那样此处。简而言之,您可以发送触发数据刷新的推送通知,这可能是Facebook和GMail所做的,以便给人的印象是内容在后台不断更新。

One option you have on iOS 7 is to have your app to refresh data in background when a special push notification is received, as discussed here. Long story short, you can send a push notification that triggers the data refresh and it's probably what Facebook and GMail do, in order to give the impression that the content was constantly updated in background.

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

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