Runtime Permissions
AFPermissions checks and requests the runtime permissions AFCore features rely on, with the same calls on Android and iOS. Your app decides when to ask; the SDK shows the system prompt and reports the result in one shared set of statuses.
What you can do
- Check or request a permission with one call: camera, location (approximate, precise or "Always"), physical activity, Bluetooth and notifications.
- Read the same statuses on both platforms, including when location was granted only at approximate accuracy.
- Send the member to the app's Settings page after a permission was denied.
- Android: register your foreground Activity once, and the SDK owns the request and result plumbing.
Key APIs
| Call | What it is for |
|---|---|
AFPermissions.getPermissionStatus(permission) | Read the current status |
AFPermissions.requestPermission(permission) | Show the system prompt when needed |
AFPermissions.openAppSettings() | Open the app's Settings page |
AFPermissions.registerLifecycle(activity) | Android: register the Activity that shows prompts |
Example
- Android (Kotlin)
- iOS (Swift)
// Once, in your foreground Activity's onCreate()
AFPermissions.registerLifecycle(this)
// Just before the feature that needs it
lifecycleScope.launch {
if (AFPermissions.getPermissionStatus(Permission.CAMERA) != PermissionStatus.GRANTED) {
val status = AFPermissions.requestPermission(Permission.CAMERA)
if (status != PermissionStatus.GRANTED) showOpenSettings { AFPermissions.openAppSettings() }
}
}
Task {
let current = try await AFPermissions.shared.getPermissionStatus(permission: .camera)
if current != .granted {
let status = try await AFPermissions.shared.requestPermission(permission: .camera)
if status != .granted { showOpenSettings { AFPermissions.shared.openAppSettings() } }
}
}
Ask just in time, when the member reaches the feature, and explain why before the system prompt appears.
Learn more
- API Reference for
AFPermissions,PermissionandPermissionStatus. - Complete integration guides, including the platform setup each permission needs, are in AIDE Docs.