the idea is that every 29 minutes I will call a method that refreshes the access token to keep it alive
It’s unlikely you’ll be able to achieve this goal. iOS has many different ways to run in the background, but none of them allow you to get executed at consistent intervals like this.
The closest I can think of is the
NSURLSession, possibly combined with
-URLSession:task:willBeginDelayedRequest:completionHandler:. There’s a couple of problems with this approach:
earliestBeginDatemeans exactly what it says. The task won’t necessarily start at that time, it just won’t start before that time.
NSURLSessionhas a resume rate limiter to prevent you from abusing features like this to run indefinitely in the background. See NSURLSession’s Resume Rate Limiter.
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"