CLLocationManager: stopUpdatingLocation() method
The stopUpdatingLocation() method stops continuous updates and cancels any unsettled requestLocation().
Syntax
stopUpdatingLocation()Parameters
None.
Return value
None (undefined).
Exceptions
None. Calling it when not updating doesn't throw.
Description
- After the call,
locationupdateno longer fires. Not verified in the simulator. - An unsettled
requestLocation()is rejected withname'AbortError'. - The runtime no longer keeps this
manageralive on account of continuous updates. - Call it when leaving a view controller that uses location; otherwise location stays on.
Examples
js
const manager = new CLLocationManager();
const pending = manager.requestLocation();
manager.stopUpdatingLocation();
pending.catch((err) => {
console.log(err.name);
});Result: when authorized, prints AbortError. Without authorization, requestLocation() rejects immediately and prints NotAllowedError.
Corresponding iOS API
-[CLLocationManager stopUpdatingLocation].
See also
startUpdatingLocation(): starting continuous updates- Installing
@nacrejs/core-location