Reputation: 126
I want to update my sqlite database in my iPhone app in every 2 hrs from the server.
Is there any way to call web services from the background even the app is not active?
Upvotes: 0
Views: 540
Reputation: 6147
You can't run your app in background for doing this. You're app is only allows to run in background for doing Audio Playback, VoIP and Task Completion (till 10min after going to background). But you could do the update once in 2hours when the user starts the app? doing something with push notification to inform the user? But you can't just run something every two hours in background.
Upvotes: 1
Reputation: 187034
You can't do this. The best you can do is sync when the app starts up. And if its backgrounded, you wait until they bring it to the foreground and can sync if it's been longer than 2 hours since the app was last in the foreground.
Apple won't let you do these battery draining and CPU stealing things. And really, you don't even need to. If your app isn't using the data, then it doesn't need to be up to date.
Upvotes: 2