StartUpdatingLocation Vs Location Service

I am having a problem regarding a location service with a significant change.

Apple documentation says: “If you use the standard location service or the significant change service to receive location events, the way you get these events is the same.”

but in the case of the "location-based service with a substantial change" I cannot receive the callbacks that I receive in the case of the "location-based service". Please let me know if anyone has any data?

+3
source share
1 answer

startUpdatingLocation updates the location when it is called for the first time, and then when the distance filter value exceeds.

But startMonitoringSignificantLocationChanges when a significant change in position occurs.

See CLLocationManager for more details.

startUpdatingLocation

Starts the generation of updates that inform users about their current location, etc.

- (void)startUpdatingLocation Discussion

This method returns immediately. Calling this method calls the location manager to get the initial location fix (which may take a few seconds) and notify its delegate by calling its locationManager: didUpdateLocations: method. (In iOS 5 and earlier, the location manager calls locationManager: didUpdateToLocation: fromLocation: instead.) After that, the receiver generates update events, especially when the value in the distanceFilter property is exceeded. Updates may be, however, in other situations. For example, the receiver may send another notification if the equipment collects a more accurate read of the location.

This method is not called several times in a row automatically; as a result, new events are generated. Calling stopUpdatingLocation in the meantime, however, raises a new start event to dispatch the next time you call this method.

If you start this service and your application is paused, the system stops the delivery of events until the application starts (in the foreground or in the background). If your application terminates, the delivery of new location events in general stops. Therefore, if your application should receive the location of the event while in the background, it should include UIBackgroundModes (indicating the location value) in the Info.plist file.

In addition to your delegation object that implements the locationManager: didUpdateLocations: method, it must also implement the locationManager: didFailWithError: method to respond to potential errors.


startMonitoringSignificantLocationChanges

Start generating updates based on significant change location.

- (void)startMonitoringSignificantLocationChanges Discussion

This method initiates the delivery of location events asynchronously, returning shortly after its call. Placements are delivered to your delegates by the locationManager: didUpdateLocations: method. The first Event to be delivered is usually the most recent location-cached event (if any), but may be a new event in some cases. Getting the current location fix may take a few extra seconds, so be sure to check the timestamps for the location events in your delegate.

After the current location correction is returned, the receiver generates an event update only when a significant change in users location is detected. For example, it can generate a new event when a device becomes connected to another cell. It does not rely on the value in the distanceFilter property to generate events. calling this method several times in a row does not work automatically when creating new events. calling stopMonitoringSignificantLocationChanges between them, however, does cause a new start event to be dispatched the next time the Method is called.

If you run this service, and your application will subsequently, the system automatically restarts the application in the background if a new event occurs. In this case, the options dictionary passed to locationManager: didUpdateLocations: method your application delegate contains the UIApplicationLaunchOptionsLocationKey key to indicate that your application was launched due to a location event. After resuming, you must still configure the location manager object and call this method to continue receiving location events. When you restart the location service, the current event is delivered to your delegate immediately. In addition, the location property of your location, the manager object is populated by the most recent location object, even before you begin to provide location services.

In addition to your delegation object that implements the locationManager: didUpdateLocations: method, it must also implement the locationManager: didFailWithError: method to respond to potential errors.

Note Applications can wait for a notification as soon as the device moves 500 meters or more from a previous notification. He should not expect notification more than once every five minutes. If the device can retrieve data from the network, the location manager is much more likely to deliver notifications in a timely manner.

+6
source

All Articles