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"