Execute a method with the closed application "Service"

Asked

Viewed 250 times

3

On Android it is possible to send notifications, make queries via http, execute methods, all through a Service without the user need to necessarily run the application, just the fact that the service is active, everything happens naturally. I see that on iOS there is no such concept of Services.

How do I run a simple method (from time to time) without the user having to open the application manually, ie a concept of "Service".

  • Hello, what’s the real need for a service running? As I mentioned in the other question, background on iOS is quite limited. If you are building an app from a code/app made for Android that makes intense use of this Feature you will have big problems if you do not try to restructure your architecture to the limitations of iOS.

1 answer

3


Depends on what you mean by "time to time".

In fact on iOS does not have all this freedom that exists on Android. There are Background Modes (see table 3-1), each for a specific need. I believe the closest you need is the fetch:

The app regularly downloads and processes small Amounts of content from the network.

What happens in this case is that in implementing the delegate application:performFetchWithCompletionHandler:, the own iOS decides the frequency of execution of this task, based on each device, usage, network availability and other factors, then you will have about 30 seconds (see in the link discussion) to do everything you want until the application is finished again.

Anyway, I believe the most you can get is this.

  • Thanks for the help, so with this I can run an http request for example without the user actually being in the application?

  • 1

    Exactly, remembering the limitation of 30 seconds to complete the whole process and the periodicity, that there is no way to define, is an algorithm of the system itself, for each type of user.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.