Authorization¶
public classAuthorization
Location permission management — request and monitor authorisation status.
Access via BGGeo.instance.authorization.
Members¶
getState¶
public func getState() ->BGGeo.ProviderChangeEvent
Retrieve the current location-services authorization state.
See also
- onProviderChange to subscribe to future authorization changes.
let bgGeo = BGGeo.shared
let providerState = bgGeo.authorization.getState()
print("- Provider state:", providerState)
requestPermission¶
public func requestPermission(_ permission:Permission? = nil) async -> PermissionStatus
Requests location and motion permission — together, or each one separately.
With no argument, requests everything the current configuration requires:
location per GeolocationConfig.locationAuthorizationRequest, then the motion
permission — the same set start requests. Pass a Permission to
request one permission at a time and control exactly when each system dialog
appears:
| Argument | Requests | Resolves with |
|---|---|---|
| (none) | Location per configuration, then motion | The location AuthorizationStatus; the motion outcome stays silent |
Permission.Location |
Location only — motion untouched | The location AuthorizationStatus |
Permission.Motion |
Motion only | AuthorizationStatus.Always when granted |
The location forms resolve when either WhenInUse or Always is granted,
regardless of the configured level, and resolve immediately when permission is
already granted. Denial rejects with the bare AuthorizationStatus value.
The no-argument form skips the motion step when
ActivityConfig.disableMotionActivityUpdates is true — and, on iOS, when
NSMotionUsageDescription is absent from Info.plist (requesting motion without
it would terminate the app).
Each call is independently awaitable: the returned promise settles only when
its own request fully resolves, and the SDK serializes permission requests
internally — await one call, then issue the next, and each dialog appears in
order, never stacked.
Android¶
A motion denial rejects with AuthorizationStatus.Denied while a new
request can still show the system dialog, and with
AuthorizationStatus.DeniedAlways once Android permanently denies the
permission (two user denials) — after that, only the device's app-settings
screen can restore it.
iOS¶
The motion permission is one-shot — iOS never re-prompts. A user denial rejects
with AuthorizationStatus.DeniedAlways: the state is permanent and only
the Settings app can restore it (the motion form never rejects with plain
AuthorizationStatus.Denied). The rejection can also carry
AuthorizationStatus.Restricted (system-wide Fitness Tracking is off or
the hardware is absent — not recoverable from the app's own Settings page) or
AuthorizationStatus.NotDetermined (no dialog could be shown, e.g. the
app was backgrounded). If the location dialog has already been shown and the
current grant does not match the configured request, the SDK presents an alert
offering to direct the user to the app's Settings page.
Note¶
The SDK automatically requests every required permission when you call
start, startGeofences, or getCurrentPosition. Calling
this method first resolves the dialogs ahead of time, so those methods find
everything granted and show nothing.
See also
- Permission
- GeolocationConfig.locationAuthorizationRequest
- ActivityConfig.disableMotionActivityUpdates
- GeolocationConfig.disableLocationAuthorizationAlert
- GeolocationConfig.locationAuthorizationAlert
- AppConfig.backgroundPermissionRationale (Android)
- requestTemporaryFullAccuracy (iOS 14+)
Request each permission separately¶
let bgGeo = BGGeo.shared
Task {
let locationStatus = await bgGeo.authorization.requestPermission(.location)
print("[requestPermission] location: \(locationStatus)")
let motionStatus = await bgGeo.authorization.requestPermission(.motion)
print("[requestPermission] motion: \(motionStatus)")
}
Request everything at once¶
let bgGeo = BGGeo.shared
// Listen to onProviderChange to be notified when location authorization changes occur.
let subscription = bgGeo.onProviderChange { event in
print("[providerchange] \(event)")
}
// First ready the plugin with your configuration.
bgGeo.ready { config in
config.geolocation.locationAuthorizationRequest = .always
}
// Manually request permission with configured locationAuthorizationRequest.
Task {
let status = await bgGeo.authorization.requestPermission()
print("[requestPermission] status: \(status)")
}
requestTemporaryFullAccuracy¶
Request temporary full-accuracy location authorization. [iOS 14+]
iOS 14 allows users to grant only reduced location accuracy. This method
presents the system dialog
(requestTemporaryFullAccuracyAuthorization)
requesting full accuracy for the lifetime of the current app session.

Configuration — Info.plist¶
Add the Privacy - Location Temporary Usage Description Dictionary key
to your Info.plist:

The dictionary keys (e.g. Delivery) are passed as purposeKey. The
corresponding value is the message shown to the user explaining the
purpose of your request.
The dialog fails to present if:
- The Info.plist entry for purposeKey is missing.
- The app is already authorized for full accuracy.
- The app is in the background.
Note
On Android and iOS versions below 14, this method returns
AccuracyAuthorization.Full immediately without presenting a dialog.
See also - ProviderChangeEvent.accuracyAuthorization
let bgGeo = BGGeo.shared
let subscription = bgGeo.onProviderChange { event in
if event.accuracyAuthorization == CLAccuracyAuthorization.reducedAccuracy.rawValue {
Task {
do {
let accuracyAuthorization = try await bgGeo.authorization.requestTemporaryFullAccuracy(purpose: "Delivery")
if accuracyAuthorization == CLAccuracyAuthorization.fullAccuracy.rawValue {
print("[requestTemporaryFullAccuracy] GRANTED: \(accuracyAuthorization)")
} else {
print("[requestTemporaryFullAccuracy] DENIED: \(accuracyAuthorization)")
}
} catch {
print("[requestTemporaryFullAccuracy] FAILED TO SHOW DIALOG: \(error)")
}
}
}
}