Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 9 Location Update Background task after 3 minutes

I've been digging into this code which is using a basic timer to check for location updates. I then have it sending lat/lng to a server.

http://mobileoop.com/background-location-update-programming-for-ios-7 https://github.com/voyage11/Location

It's working well when plugged in and hooked up through XCode, however when I unplug and take the device mobile, the OS seems to always kill the background thread exactly after 3 minutes. So if I set the timer to run every 30 seconds, I'll get ~6 updates until I bring the app up to the foreground.

I have read that max background execution time is 3 minutes, but as I see it this code is resetting the background task after 1 minute, so I'm not sure why I'm seeing this.

There must be some way around this. Anything I can do here?

EDIT: this helped me: allowsBackgroundLocationUpdates in CLLocationManager in iOS9

like image 824
aherrick Avatar asked Sep 01 '15 01:09

aherrick


2 Answers

se:

if ([self.locationManager respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)]) {
    [self.locationManager setAllowsBackgroundLocationUpdates:YES];
}

This is needed for background location tracking.

like image 181
Nilesh Avatar answered Oct 13 '22 00:10

Nilesh


In case anyone else runs into this issue, the code at the github repo listed above - https://github.com/voyage11/Location - has recently been updated with a fix for iOS 9, that will allow the GPS to continuously poll in the background without the thread getting terminated after 3 minutes.

like image 25
haplo1384 Avatar answered Oct 12 '22 22:10

haplo1384