StartUpdateLocations in Background, didUpdatingToLocation only called 10-20 times

后端 未结 3 2092
心在旅途
心在旅途 2020-12-01 05:16

Testing Device: iPhone 5 (iOS 7)

I have an app that uses RegionMonitoring and updateLocation. If a region is entered, didEnterRegion<

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 05:30

    In background timer will not run, so here your timer object will not respond, You need to create background task handler, check comment of below link,

    How to run the timer in background of the application?

    In background if you want to continue location service than you need to set pausesLocationUpdatesAutomatically flag, flag info on

    pausesLocationUpdatesAutomatically flag info

      if ([self.locationManager respondsToSelector:@selector(pausesLocationUpdatesAutomatically)]) {
      self.locationManager.pausesLocationUpdatesAutomatically = NO;
      }
    

    check my comment on Location service going to "Inactive" state in iPhone 5

    For location manager there below are the CLLocationManagerDelegate methods for location update,

       - (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation [Deprecated in __IPHONE_6_0]
    
      - (void)locationManager:(CLLocationManager *)manager
     didUpdateLocations:(NSArray *)locations __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);
    

    Where you found

      - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation ??
    

提交回复
热议问题