Reputation: 555
I've developed an iOS app that uses geofences in the background. When such event happens, I want to send an HTTP request. If that request fails, I want to retry it several times with some seconds of delay between the calls. I am using UIBackgroundMode
for 'location' already.
My NSTimer
scheduled looks like this:
dispatch_async(dispatch_get_main_queue(), ^{
[NSTimer scheduledTimerWithTimeInterval:30.0 target:self selector:@selector(updateFence:) userInfo:fence repeats:NO];
});
This works fine in foreground and 'normal' background, but not if the app is killed and is started by iOS for a new geofence event. In that case the first http call works but when I then start the NSTimer
with 30s delay it will never call the target selector.
Is there anything, beside UIBackgroundMode
, that I need to use to be able to use NSTimer
in (killed-) background? Am I scheduling the Timer on the wrong runloop/thread for that special background mode to work?
Upvotes: 0
Views: 119
Reputation: 50129
when it is killed, it is killed. timers won't work - end of story - sorry
alternatives might be background app refreshes or silent pushes OR a user-visible local notification
Upvotes: 1