Skip to content

State

public structState

Read-only snapshot of the SDK's current runtime state.

let bgGeo = BGGeo.shared
let state = bgGeo.state
print("[state] enabled:", state.enabled, "trackingMode:", state.trackingMode)
Properties
Property Type Description
enabled Boolean Whether the SDK is currently tracking.
isMoving Boolean Whether the device is currently in motion.
trackingMode TrackingMode Current tracking mode: LOCATION or GEOFENCE.
odometer Double Distance travelled in metres since last reset.
schedulerEnabled Boolean Whether the scheduler is currently active.
didDeviceReboot Boolean Whether the device rebooted since the SDK was last running.

Members

didDeviceReboot

public let didDeviceReboot: Bool

true when the app was launched after a device reboot.

didLaunchInBackground

public let didLaunchInBackground: Bool

iOS only true when the app was relaunched in the background by the OS — for example, due to a background fetch, geofence exit, or stationary geofence transition. On Android, background launch is handled by the Headless Task mechanism — this property does not apply.

enabled

public let enabled: Bool

true when the SDK is actively tracking — i.e. BGGeo.start or BGGeo.startGeofences has been called and not yet stopped.

isFirstBoot

public let isFirstBoot: Bool

true on the very first launch after the app is installed.

isMoving

public let isMoving: Bool

true when the SDK is in the moving state (location services active); false when stationary.

let bgGeo = BGGeo.shared

// If the SDK is currently in the *stationary* state:
let sub = bgGeo.onMotionChange { location in
    print("[onMotionChange] isMoving? \(location.isMoving)")
}

bgGeo.changePace(true)
// config.isMoving is now true.

odometer

public let odometer: Double

Accumulated distance traveled since the last odometer reset, in meters.

See also - odometerError - BGGeo.setOdometer - BGGeo.getOdometer

odometerError

public let odometerError: Double

Accumulated positional error in the odometer measurement, in meters.

Reflects noise introduced by low-accuracy location samples. Use LocationFilterConfig.odometerAccuracyThreshold to filter out low-accuracy samples from odometer calculations.

schedulerEnabled

public let schedulerEnabled: Bool

true when a AppConfig.schedule is configured and BGGeo.startSchedule has been called. BGGeo.stopSchedule sets this to false.

trackingMode

public let trackingMode:TrackingMode

Current tracking mode.

Value Mode Description
0 Geofences Geofence monitoring only — no active location tracking.
1 Location Location tracking and geofence monitoring.
let bgGeo = BGGeo.shared

Task {
    do {
        try await bgGeo.start()
        print("Tracking mode: \(bgGeo.config.trackingMode)")
        // trackingMode == .location

        try await bgGeo.startGeofences()
        print("Tracking mode: \(bgGeo.config.trackingMode)")
        // trackingMode == .geofence
    } catch {
        print("Error: \(error)")
    }
}