Background pull requests.

Hi all.


I need to do a background pull request every 10 seconds using Swift.


For reasons i won't go into a i can't do push requests.


Is there any way of doing this reliably?


From what I know background tasks can run when the screen is off but their execution time may vary depending on when the OS wakes up the background thread.


Is there any way round this?


Thanks.

Replies

I need to do a background pull request every 10 seconds using Swift.

What platform are you targeting?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi Eskimo,


Thanks for your reply,


iOS.

OK, this specific goal:

I need to do a background pull request every 10 seconds using Swift.

is not achievable on iOS. Once your app is moved to the background, it is typically suspended, and it can’t make network requests while it’s suspended. There are things you can do to hold off that suspension, and also get resumed in the background, but nothing will give you regular background executable time every 10 seconds.

Even if you could, you’d quick run through the user’s battery.

You need to rethink your approach. I specifically recommend that you reconsider using push notifications. There’s a reason Apple puts so much emphasis on push notifications. In a push model, you offload this work to a server that doesn’t have to worry about all day battery life.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"