| Android | iOS | JVM | JS | WasmJS | macOS | tvOS | watchOS |
|---|---|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Adds a BluetoothPermission to Permissions. Register this permission by calling PermissionsBuilder.registerBluetoothPermission()/PermissionsBuilder.registerBluetoothPermissionIfNotRegistered().
Installing
This library is available on Maven Central. You can import Kaluga Permissions Bluetooth as follows:
repositories {
// ...
mavenCentral()
}
// ...
dependencies {
// ...
implementation("com.splendo.kaluga.permissions:bluetooth:$kalugaVersion")
}
Please check general permissions documentation for full documentation
Android manifest
The Android permissions are scoped by BluetoothPermission.Type, and each module declares only the permissions it needs, so an app inherits only what it uses:
bluetooth-clientdeclaresBLUETOOTH_SCAN,BLUETOOTH_CONNECT, andACCESS_FINE_LOCATION(maxSdkVersion="30", since location is mandatory for scanning below API 31).bluetooth-serverdeclaresBLUETOOTH_ADVERTISE.bluetooth-coredeclares the legacyBLUETOOTH/BLUETOOTH_ADMIN(maxSdkVersion="30") shared by both.
Location is intentionally left to the app on API 31+, as it depends on your use case:
- If you scan for location (
BluetoothPermission.Type.Client(useForLocation = true)), declareACCESS_FINE_LOCATION(without amaxSdkVersion) in your manifest. - Otherwise, declare
BLUETOOTH_SCANwithandroid:usesPermissionFlags="neverForLocation"in your manifest to decouple scanning from the location permission, and keepuseForLocation = false(the default).