Constants
Every constant is a Swift enum with a raw value carrying the number or string
the engine exchanges. Config takes the raw value, so pass
DesiredAccuracy.high.rawValue rather than the case itself.
Desired accuracy
Config(desiredAccuracy: DesiredAccuracy.high.rawValue)| Constant | Value | Meaning |
|---|---|---|
.navigation | -2 | Highest precision; only for turn-by-turn. Heaviest battery cost. |
.high | -1 | GPS-grade. The default, and what tracking is tuned for. |
.medium | 10 | ~10 m; balanced provider, GPS may not engage. |
.low | 100 | ~100 m; network/cell-grade. |
.veryLow | 1000 | ~1 km. |
.lowest | 3000 | ~3 km. Effectively “which city”. |
The accuracy filter rejects fixes worse than locationFilterMaxAccuracy
(100 m by default), so setting LOW or coarser while that gate is at its
default produces a stream that is mostly rejected. Change both or neither.
Log level
Config(logLevel: LogLevel.info.rawValue)| Constant | Value |
|---|---|
.off | 0 |
.error | 1 |
.warning | 2 |
.info | 3 |
.debug | 4 |
.verbose | 5 |
This controls persistence only: the engine always mirrors its lines to
os_log. The level decides what is written to the on-device log database that
getLog() reads and uploadLog() ships. See
Logging & debugging.
Authorization status
Returned by requestPermission() and carried in getState().authorization.
| Constant | Value | Meaning |
|---|---|---|
.notDetermined | 0 | Nothing asked yet. |
.restricted | 1 | Blocked by policy (device management). |
.denied | 2 | Refused; no location. |
.always | 3 | Background location granted. |
.whenInUse | 4 | Foreground only. |
Accuracy authorization
| Constant | Value | Meaning |
|---|---|---|
.full | 0 | Precise location. |
.reduced | 1 | The user granted approximate location only (API 31+). |
Reported by getProviderState(). Approximate location (iOS 14+) is a coarse
grid: most fixes fail the accuracy gate and tracking is effectively unusable,
so it is worth surfacing to the user — or asking for a temporary upgrade with
requestTemporaryFullAccuracy(purpose:)
— rather than debugging it as a bug.
Activity types
The classification behind the motion state machine, on
onMotionChange and location.activity.type.
| Constant | Wire value |
|---|---|
.still | still |
.onFoot | on_foot |
.walking | walking |
.running | running |
.onBicycle | on_bicycle |
.inVehicle | in_vehicle |
.unknown | unknown |
ActivityType.from(wire) maps a raw string back, falling back to UNKNOWN
for anything unrecognised rather than throwing — a new activity class from a
future Play Services release degrades instead of crashing.
License codes
BGeoError is a plain Error carrying the engine’s own code and message.
It is deliberately not an enum: a code this SDK version has never seen stays
diagnosable through code verbatim instead of collapsing into a
.unknown case.
| Code | When |
|---|---|
LICENSE_MISSING | Release build, no key in Info.plist |
LICENSE_INVALID | Bad signature or malformed token |
LICENSE_EXPIRED | Key expired before this SDK build |
LICENSE_APP_MISMATCH | Key not bound to this bundle id / Team ID |
DISABLED | Operation needs tracking to be running |
NOT_FOUND | No such record (e.g. destroyLocation with an unknown uuid) |
INVALID_GEOFENCE | Missing identifier, non-positive radius, bad coordinates |
DECODE_ERROR | The engine sent something this SDK could not decode |
do { try await BackgroundGeolocation.start()} catch let error as BGeoError { switch error.code { case "LICENSE_EXPIRED": showRenewalPrompt() default: print("bgeo:", error.code, error.message ?? "") }}The same codes arrive through
onLocationError as a
LocationErrorEvent, so a thrown getCurrentPosition() failure and a streamed
watch failure are handled the same way.