Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

180 Seconds Limit #9

Open
yreaction opened this issue Sep 24, 2015 · 5 comments
Open

180 Seconds Limit #9

yreaction opened this issue Sep 24, 2015 · 5 comments

Comments

@yreaction
Copy link

Hi:

First of all, thanks for this contribution.

I've been looking as you to reach a proper solution of unlimited update location every X time. Unfortunately I'm not able to do it even with your repository. I have set up everything, but still with this one and other solutions there is no way of break the 180 second limit.

@shanemileham
Copy link

I'm having the same issue while running on iOS9. The restartLocationUpdates: method is being called each minute, but backgroundTimeRemaining does not get reset. This leads to my app getting killed after 180 seconds as well.

@voyage11 - Do you know why this is happening or have a possible solution? I've been researching for hours and haven't found a solution that isn't ridiculously extravagant yet. Thanks for putting together this library!

@shanemileham
Copy link

Found it! Solution was posted in the comments here:
http://mobileoop.com/background-location-update-programming-for-ios-7#comment-433

To make it work on ios 9 change the singleton initializer in LocationTracker.m to

+ (CLLocationManager *)sharedLocationManager {
static CLLocationManager *_locationManager;

@synchronized(self) {
if (_locationManager == nil) {
_locationManager = [[CLLocationManager alloc] init];
if([_locationManager respondsToSelector:@selector(allowsBackgroundLocationUpdates)]){
[_locationManager setAllowsBackgroundLocationUpdates:YES];
}
_locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
}
}
return _locationManager;
}

@yreaction
Copy link
Author

Totally right. Thanks!

@sergii-frost
Copy link

Hi,
I've been successfully using current approach for iOS 7-8, updated app to iOS 9 with using [_locationManager setAllowsBackgroundLocationUpdates:YES]; but found an interesting case:

  1. Start app for first time, make all configs with background tasks etc
  2. Send app to background, check [UIApplication sharedApplication].backgroundTimeRemaining property --> it starts to count down from 180 to 0
  3. Make app active
  4. Send app to background, check [UIApplication sharedApplication].backgroundTimeRemaining property --> it is equal to CGFLOAT_MAX

Has anyone else faced this issue? It happens only on first app -> background.

@sergii-frost
Copy link

I've figured issue why I was getting issue described in previous comment, but it may be helpful to someone else:

I was calling [_locationManager setAllowsBackgroundLocationUpdates:YES]; in the handler of UIApplicationDidEnterBackgroundNotification notification, and it was too late actually. This method should be called whenever _locationManager is initialized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants