Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to keep GPS app running in background without pauses
    primarykey
    data
    text
    <p>I have a problem keeping the GPS running in background. </p> <p>I succeded to keep the GPS running when the app is in background, but it stops sometimes. I noticed that it stops when i enter in a building and i stay there for 2-3 hours. "Stops" means that i don't receive any GPS point even though the location service icon is still on. Then when i get out i don't receive any points until I bring my application to foreground.</p> <p>I set the pausesLocationUpdatesAutomatically property to NO.</p> <p>So, everything works fine until i get into a location with weak gps signal. When i get out of that area i don't receive points anymore, even though I should because the gps signal is now good.</p> <p>And here is my code when the applications enters in background:</p> <pre><code>- (void)applicationWillResignActive:(UIApplication *)application { NSLog(@"[AppDelegate]: Application entering in background!"); if(doesUserWantGPSTracking) { [self stopGPS]; UIApplication *app = [UIApplication sharedApplication]; bgTask = [app beginBackgroundTaskWithExpirationHandler: ^{ dispatch_async(dispatch_get_main_queue(), ^{ if( bgTask != UIBackgroundTaskInvalid ) { [app endBackgroundTask:bgTask]; bgTask = UIBackgroundTaskInvalid; } }); }]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [self startGPS]; dispatch_async(dispatch_get_main_queue(), ^{ if( bgTask != UIBackgroundTaskInvalid ) { [app endBackgroundTask:bgTask]; bgTask = UIBackgroundTaskInvalid; } }); }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload