parek
parek

Reputation: 782

HTTP Request as background task with local notifications in iOS

If you aren't that into Android, there's something called a "background-service" for the applications in that OS. Which basically gives the developer a opportunity to make some background tasks without forcing the application to be in foreground.

So are there something like this in iOS? (Version 5 and newer) What I basically want to do is to call a API and fetch some JSON data every minute, then parse the result and then present a local notification banner to the user depending on the result that were fetched from the HTTP request. I hardly believe that this shouldn't be possible in iOS, but I haven't found anything like this yet.

  1. Call the API once every minute and fetch some JSON data.
  2. Parse the JSON data into and add some logic to handle the data.
  3. If a local notification should be presented or not, depends on the result from the request.

Upvotes: 1

Views: 2304

Answers (1)

alleus
alleus

Reputation: 6077

This can only be done in a very limited manner. Pure background processes are only allowed in special forms (for example media players, VOIP or location based services). You can start limited background tasks with beginBackgroundTaskWithExpirationHandler:, but they won't run forever.

More information can be found here: Run app for more than 10 minutes in background

Upvotes: 1

Related Questions