Reputation: 2139
I've developed app which should process some data every 15 min. So I added voip flag into plist file. And use setKeepAliveTimeout with 900 sec(15 min). Also added background task functionality which processes some data. Processing of data takes up to 10 seconds.
The problem is that app wakes up NOT in time. Sometimes after 12 min, sometimes after 16 min etc. But I need exactly in 15 min.
How to solve the following problem?
iOS version is 5.0+
If it's iOS's specific please provide me official reference into the apple's api document where this mentioned .
Upvotes: 3
Views: 1649
Reputation: 3031
setKeepAliveTimeout:handler:
is not a general purpose interval scheduler. It allows you to set the maximum interval between invocations of the supplied handler. The purpose of the function is to help you keep your connections from timing out or falling behind your VOIP applications standards (for things like online/away status).
So the first parameter (timeout
) tells iOS to call your handler in no more than 15 minutes. If the OS decides that it's got some cycles to spare at 12 minutes, it might call your handler. Or in 7 minutes, or 15.
If you need finer grained control of the interval, you should set a smaller timeout window and just ignore invocations that aren't important to you. But the invocations will still going be fairly irregular.
In general, there is currently no way to make it wake your app on a precise schedule. You must adhere to iOS' limited background processing options, all of which are designed to give the OS a lot of leeway to manage overall priorities and resource needs across ALL processes.
Upvotes: 2