ChangelogEdit pageSTAFFOpen dashboard

Permissions

struct · Swiftobject · Kotlinobject · TypeScriptfinal class · Dart

Bubbl.permissions reads where the device stands on notifications and location, and asks for them. BubblPermissionStatus is what it answers with.

Asking through Bubbl.permissions shows Bubbl's privacy view first when the dashboard says so, then the system prompt. It works from anywhere in the app, with no activity or view controller of yours. You don't have to use it: Bubbl follows whatever permission your app holds, however it was granted. More in Permissions and privacy.

Bubbl.permissions#

Every function answers null (nil on iOS) before start, and on a device below the runtime minimum. openSettings() works before start, since it needs nothing from Bubbl.

Bubbl.permissions is the object Bubbl.Permissions. From Java, call Bubbl.Permissions.status() and the callback functions, which are @JvmStatic.

status(): BubblPermissionStatus?Android only
Where the device stands now. Synchronous. null before start.
suspend fun requestNotifications(): BubblPermissionStatus?Android only
Asks for notifications. Android 13 and later only; on earlier versions there's nothing to ask.
suspend fun requestLocation(always: Boolean = false): BubblPermissionStatus?Android only
Asks for location while the app is in use, or with always for geofences while it's closed. Android asks for "Allow all the time" in a second step.
requestNotifications(callback: Bubbl.Callback<BubblPermissionStatus?>)Android only
requestNotifications() with the result delivered on the main thread.
requestLocation(always: Boolean, callback: Bubbl.Callback<BubblPermissionStatus?>)Android only
requestLocation(always) with the result delivered on the main thread. always has no default here.
openSettings()Android only
Opens the app's page in system settings, for a permission the user refused for good (one of the app's own, like the camera, too). Before start it uses the context App Startup gives Bubbl, so it does nothing if the app removed Bubbl's App Startup initializer.

Bubbl.permissions is a BubblPermissions (public struct BubblPermissions: Sendable). iOS shows each prompt only once: after a refusal, send the user to openSettings().

func status() -> BubblPermissionStatus?iOS only
Where the device stands, as Bubbl last looked: at start, when the app comes to the front and after asking. Synchronous. nil before start, and can be nil just after it, until Bubbl's first look.
func requestNotifications() async -> BubblPermissionStatus?iOS only
The privacy view if the dashboard says so, then the system prompt.
func requestLocation(always: Bool = false) async -> BubblPermissionStatus?iOS only
The same for location; with always, the second step from "While Using" to "Always" too.
func requestNotifications(completion: @escaping @MainActor @Sendable (BubblPermissionStatus?) -> Void)iOS only
requestNotifications() for code that can't await. completion runs on the main thread.
func requestLocation(always: Bool, completion: @escaping @MainActor @Sendable (BubblPermissionStatus?) -> Void)iOS only
requestLocation(always:) for code that can't await. always has no default here.
func openSettings()iOS only
Opens the app's page in Settings. Opens on the main thread, whichever thread calls it.

Bubbl.permissions is a BubblPermissions (final class, with no public constructor). Every function is asynchronous, status() included.

Future<BubblPermissionStatus?> status()Flutter only
Where the device stands now. null before start.
Future<BubblPermissionStatus?> requestNotifications()Flutter only
Asks for notifications, with the privacy view first when the dashboard says so.
Future<BubblPermissionStatus?> requestLocation({bool always = false})Flutter only
Asks for location while the app is in use, or with always for geofences while it's closed, which the system asks for in a second step.
Future<void> openSettings()Flutter only
Opens the app's page in system settings.

Bubbl.permissions is a plain object. Every function but openSettings returns a promise, status() included.

status(): Promise<BubblPermissionStatus | null>React Native only
Where the device stands. null before start.
requestNotifications(): Promise<BubblPermissionStatus | null>React Native only
Asks for notifications, with the privacy view first when the dashboard says so.
requestLocation(options?: { always?: boolean }): Promise<BubblPermissionStatus | null>React Native only
Asks for location while the app is in use, or with { always: true } for geofences while it's closed, as a second step. Takes an options object, not a boolean.
openSettings(): voidReact Native only
Opens the app's page in system settings, for a permission refused for good.

BubblPermissionStatus#

Where the device stands on the permissions Bubbl uses.

data class BubblPermissionStatus(notifications, location, preciseLocation).

notifications
BubblPermissionStatus.Notifications
Whether the app may show notifications.
location
BubblPermissionStatus.Location
The app's location permission.
preciseLocation
Boolean
Fine rather than approximate location.
Notifications.GRANTED
BubblPermissionStatus.Notifications
Allowed.
Notifications.DENIED
BubblPermissionStatus.Notifications
Refused.
Notifications.NOT_DETERMINED
BubblPermissionStatus.Notifications
Not asked yet.
Location.ALWAYS
BubblPermissionStatus.Location
"Allow all the time": geofences work with the app closed.
Location.WHEN_IN_USE
BubblPermissionStatus.Location
Only while the app is in use.
Location.DENIED
BubblPermissionStatus.Location
Refused.
Location.NOT_DETERMINED
BubblPermissionStatus.Location
Not asked yet.

public struct BubblPermissionStatus: Sendable, Equatable. Apps get it from Bubbl; it has no public initializer.

notifications
BubblPermissionStatus.Notifications
Whether the app may show notifications.
location
BubblPermissionStatus.Location
The app's location permission.
preciseLocation
Bool
Precise rather than approximate location. Geofences need it.
Notifications.granted
BubblPermissionStatus.Notifications
Allowed.
Notifications.denied
BubblPermissionStatus.Notifications
Refused.
Notifications.notDetermined
BubblPermissionStatus.Notifications
Not asked yet.
Location.always
BubblPermissionStatus.Location
"Always": geofences work with the app closed.
Location.whenInUse
BubblPermissionStatus.Location
Only while the app is in use.
Location.denied
BubblPermissionStatus.Location
Refused.
Location.notDetermined
BubblPermissionStatus.Location
Not asked yet.

class BubblPermissionStatus, with the two permissions as top-level enums.

notifications
BubblNotificationPermission
Whether the app may show notifications.
location
BubblLocationPermission
The app's location permission.
preciseLocation
bool
Fine rather than approximate location.
BubblNotificationPermission.granted
BubblNotificationPermission
Allowed.
BubblNotificationPermission.denied
BubblNotificationPermission
Refused: only Settings can change it (openSettings()).
BubblNotificationPermission.notDetermined
BubblNotificationPermission
Not asked yet.
BubblLocationPermission.always
BubblLocationPermission
Always, so geofences work with the app closed.
BubblLocationPermission.whenInUse
BubblLocationPermission
Only while the app is in use.
BubblLocationPermission.denied
BubblLocationPermission
Refused: only Settings can change it (openSettings()).
BubblLocationPermission.notDetermined
BubblLocationPermission
Not asked yet.

BubblPermissionStatus also has a const constructor with the three fields, a BubblPermissionStatus.fromMap(Map<String, Object?> map) factory for the object the native SDK sends, and a readable toString().

type BubblPermissionStatus, with string values.

notifications
'granted' | 'denied' | 'notDetermined'
Whether the app may show notifications.
location
'always' | 'whenInUse' | 'denied' | 'notDetermined'
The app's location permission. 'always' means geofences work with the app closed.
preciseLocation
boolean
Fine rather than approximate location.