Location
The Location API provides access to the device’s geographic location, geocoding services, system map location picking, and heading (compass) information. It is available as a global API in Scripting and can be used directly without importing any modules.
The API respects system permissions, user-selected accuracy levels, and platform limitations, and is suitable for scripts, interactive views, and supported widget scenarios.
LocationAccuracy
Defines the desired accuracy level for location data.
Type Definition
Description
-
bestRequests the highest accuracy available on the device. -
tenMetersRequests approximately 10-meter accuracy. -
hundredMetersRequests approximately 100-meter accuracy. -
kilometerRequests approximately 1-kilometer accuracy. -
threeKilometersRequests coarse accuracy within approximately 3 kilometers. -
bestForNavigationOptimized for navigation use cases, with higher update frequency and power consumption. -
reducedRequests reduced-accuracy location data, typically used when the user has granted approximate location access.
LocationInfo
Represents a geographic coordinate with an associated timestamp.
Type Definition
Properties
-
latitudeLatitude in degrees. -
longitudeLongitude in degrees. -
timestampTime when the location was recorded, in milliseconds since the Unix epoch.
LocationPlacemark
Provides a human-readable description of a geographic location, usually returned by geocoding operations.
Type Definition
Description
A placemark may include address components, administrative regions, country information, and points of interest. Field availability depends on the location and system map data.
Heading
Represents compass and orientation information derived from the device’s sensors.
Type Definition
Properties
-
headingAccuracyMaximum deviation, in degrees, between the reported heading and the true geomagnetic heading. -
trueHeadingHeading relative to true north, in degrees. -
magneticHeadingHeading relative to magnetic north, in degrees. -
timestampTime at which the heading was measured. -
x,y,zRaw geomagnetic field values for the three axes, measured in microteslas.
Authorization and Configuration
isAuthorizedForWidgetUpdates
Indicates whether the current widget is eligible to receive location updates.
accuracy
The currently configured desired location accuracy.
setAccuracy
Sets the desired accuracy level for subsequent location requests. Higher accuracy may increase power consumption and require additional permissions.
Example
Requesting Location
requestCurrent
Requests the device’s current location.
By default, a cached location is returned immediately if available. If no cached location exists, a new location request is performed.
When forceRequest is set to true, any cached location is ignored and a fresh request is always made.
Example
Forcing a fresh location request:
pickFromMap
Presents the system map interface and allows the user to manually select a location.
Example
Geocoding
reverseGeocode
Converts a geographic coordinate into human-readable address information.
Example
geocodeAddress
Converts a textual address into geographic placemark results.
Example
Heading and Compass
requestHeading
Returns the most recently reported heading. If heading updates have never been started, the result is null.
Example
startUpdatingHeading
Starts continuous heading updates.
When options.requestAlwaysAuthorization is true, the system requests "Always" authorization
instead of the default "When In Use".
The promise resolves with { mode } reflecting the authorization actually granted by the
system. If you requested "always" but mode resolves as "whenInUse", iOS did not (or
could not) prompt the user — typically because the user has already declined the upgrade
once. iOS allows only a single programmatic Always upgrade attempt; afterwards the user must
go to Settings → Privacy & Security → Location Services → Scripting → Always manually.
stopUpdatingHeading
Stops heading updates and releases related system resources.
addHeadingListener
Registers a listener that is called whenever the heading changes.
Example
removeHeadingListener
Removes a previously registered heading listener. If no listener is provided, all heading listeners are removed.
startUpdatingLocation
Starts continuous location updates. Subsequent updates are delivered to listeners registered via
addLocationListener.
When options.requestAlwaysAuthorization is true, the system requests "Always" authorization,
which is required if you intend to keep receiving updates while the app is backgrounded.
The promise resolves with { mode } reflecting the authorization actually granted. If you
requested "always" but mode resolves as "whenInUse", iOS suppressed the upgrade prompt
(only one programmatic Always upgrade attempt is permitted per app install). Direct the user
to Settings → Privacy & Security → Location Services → Scripting → Always to grant it
manually.
stopUpdatingLocation
Stops continuous location updates and releases related system resources.
This does not affect one-shot calls such as requestCurrent.
addLocationListener
Registers a listener that is called whenever a new location is reported.
Example
removeLocationListener
Removes a previously registered location listener. If no listener is provided, all location listeners are removed and continuous updates stop.
allowsBackgroundLocationUpdates / setAllowsBackgroundLocationUpdates
Whether the app receives location updates while in the background.
pausesLocationUpdatesAutomatically / setPausesLocationUpdatesAutomatically
Whether the system automatically pauses location updates when location data is unlikely to change.
showsBackgroundLocationIndicator / setShowsBackgroundLocationIndicator
Whether the status bar background indicator is shown when the app uses location services
in the background under authorizedAlways.
distanceFilter / setDistanceFilter
The minimum horizontal distance (in meters) the device must move before a new update is
generated. Use -1 to receive every movement.
headingFilter / setHeadingFilter
The minimum angular change (in degrees) required before a heading update is generated.
Use -1 to receive every change.
activityType / setActivityType
A hint that helps iOS optimize battery usage and accuracy:
"other", "automotiveNavigation", "fitness", "otherNavigation" or "airborne".
