2 Replies
      Latest reply on Nov 5, 2019 5:57 AM by Kyrsting
      soriyany Level 1 Level 1 (0 points)

        Helle there,

        I was having problem with background location services both testing on simulator and devices. locationManagerDidPauseLocationUpdates is never called as "Paused" is never logged out. locationManagerDidResumeLocationUpdates is never called as "Resume" is never logged out. 


        Below is my sample code:

         

        - (void)viewDidLoad {

            [super viewDidLoad];

             locationManager = [[CLLocationManager alloc] init];

            locationManager.delegate = self;

            if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {

                [locationManager requestAlwaysAuthorization];

            }

            [locationManager setActivityType:CLActivityTypeFitness];

         

            [locationManager setPausesLocationUpdatesAutomatically:YES];

            locationManager.distanceFilter = kCLLocationAccuracyNearestTenMeters;

            locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;

            [locationManager startUpdatingLocation];

        }

        -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{

            NSLog(@"currentLocation");

        }

        -(void)locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager{

            NSLog(@"Paused");

        }

        -(void)locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager{

            NSLog(@"Resume");

        }

        • Re: locationManagerDidPauseLocationUpdates
          Gualtier Malde Apple Staff Apple Staff (530 points)

          The reason you are not seeing these called could be how you are testing your app.

          The system will pause location updates and power down the appropriate hardware when it decides it is power efficient to do so.

          If you are testing with the device plugged in to power or tethered to Xcode for debugging, iOS will not see the need to save power and continue as is.

           

          When testing location apps, for realistic results you should be testing as it would be used in the real world and not tethered to Xcode.

          You can examine the device console log later for your NSLog() output.

            • Re: locationManagerDidPauseLocationUpdates
              Kyrsting Level 1 Level 1 (0 points)

              In iOS 13 I experience that 'locationManagerDidPauseLocationUpdates' isn't called during background tracking (on device), even if the location doesn't change during 'an extended period of time'.

               

              ('locationManager.pausesLocationUpdatesAutomatically' is set true)

               

              Before iOS 13 this wasn't an issue for me...