Core Location: best practices for switching between a meaningful location service and a standard location service?

Sometimes my application needs to use higher accuracy, more frequent standard location updates, and sometimes all it needs is significant location updates. The most common time I need to make this switch is when the application switches between the foreground and background.

When switching between these services:

  • Do I need to disable one and the other, as if they were separate services that do not affect each other?
    • Norma-> Essential:
      [myLocationManager stopUpdatingLocation]; [myLocationManager startMonitoringSignificantLocationChanges];
    • Significant-> Standard:
      [myLocationManager stopMonitoringSignificantLocationChanges]; [myLocationManager startUpdatingLocation];
  • Are these services provided to each other when they themselves are turned on, so I never need to stop them, just start them?
    • Norma-> Essential:
      [myLocationManager startMonitoringSignificantLocationChanges];
    • Significant-> Standard:
      [myLocationManager startUpdatingLocation];
  • Am I just starting a significant service when I set up the application and leave it, only if it is necessary to start and stop the standard service (additional accuracy)?
    • Initial setting:
      [myLocationManager startMonitoringSignificantLocationChanges];
    • Norma-> Essential:
      [myLocationManager stopUpdatingLocation];
    • Significant-> Standard:
      [myLocationManager startUpdatingLocation];

The documentation for the CLLocationManager is unclear in the details of this behavior. Thanks for the helpful tips!

Edit: I just found useful information on another issue, excluding the second possible behavior mentioned above, but not suggesting a better way to manage this switch: Does calling stopUpdatingLocation on the CLLocationManager stop monitoringSignificantLocationChanges

+6
source share

Source: https://habr.com/ru/post/979184/


All Articles