Android Services equivalent in iOS Swift

2019-06-01 17:53发布

问题:

I am looking for something that is equivalent to Services in Android. As far as I have searched I haven't found anything useful. I found Background Fetch but according to my understanding it cannot be used long processes.
Here is what I want to use it for.
fetch a list of twitter user ids from our web server then auto-follow those usernames in background. As there are limits in Twitter API, so the process will be long possibly 3-4 hours. Is this possible on iOS?

回答1:

There is no long-running background mode for continuous execution of apps in iOS. This doesn't really sound like the right task for a mobile device. Running a 3-4 hour background job would be bad for battery life.

You can implement the function on a server somewhere and use push notification to send updates to the device.



回答2:

An Android Service use case that is often cited is a background music service, which I have implemented as an exercise. It is not a given that a long running task actually will consume a lot of battery. Rather, it appears Apple is guaranteeing that such an event cannot happen through API design.