The BIQ Android SDK is a lightweight library that enables proof of presence for Android applications using BLE beacons. When a user enters the proximity of one of our secure beacons and is authorized for a specific event, their presence is automatically validated.
- Beacon scanning
- Secure presence validation through cryptographic signing
- Foreground/background scanning
- Boot auto-start support
- Notification support for beacon region entry
- State listeners for scanning, SDK state, and validation records
- Debugging tools and validation record inspection
In your module-level build.gradle.kts:
implementation("biq.sdk.android:biq:<latest-version>")In your project-level settings.gradle.kts:
pluginManagement {
repositories {
mavenCentral()
maven {
url = uri("https://biqprotocol.github.io/biq-sdk-android-repo/")
content {
includeGroup("biq.sdk.android")
}
}
}
}
dependencyResolutionManagement {
repositories {
mavenCentral()
maven {
url = uri("https://biqprotocol.github.io/biq-sdk-android-repo/")
content {
includeGroup("biq.sdk.android")
}
}
}
}Add the following permissions to your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>- Location & Bluetooth: Required for beacon detection and communication
- Internet: To communicate with the BIQ validation server
- Foreground/Background Service: Ensures scanning continues even when the app is not in the foreground
- POST_NOTIFICATIONS: To alert the user when entering a beacon region
- RECEIVE_BOOT_COMPLETED: Enables automatic scanning after device restarts
If using boot auto-scan, also add the following receiver:
<receiver
android:name="biq.sdk.android.receivers.BootReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>BiqController.Builder(this)
.build()
.setNotificationEntryPoint(this::class.java) // Optional
.setBootAutoScan(true) // Optional, default: false
.setDebugMode(true) // Optional, default: false
.init(
apiKey = "<your_api_key>",
refreshToken = "<your_refresh_token>"
)lifecycleScope.launch {
when (val result = BiqController.getInstance().startPresence()) {
is ConnectionState.Success -> {
// Presence started successfully
val currentState = result.state
}
is ConnectionState.Error -> {
// Handle error
val errorMessage = result.message
val exception = result.exception
}
is ConnectionState.MissingPermission -> {
// Request the missing permission
val permission = result.permission
}
}
}
BiqController.getInstance().stopPresence()val listener = object : BiqController.BiqStateListener {
override fun onSdkStateChanged(newState: BiqPresenceState) {
// Handle SDK state change
}
override fun onScanningStateChanged(newState: BiqScanningState) {
// Handle scanning state change
}
override fun onValidationRecordsChanged(newRecords: List<PresenceProofResponseDto>) {
// Handle validation record updates
}
}
BiqController.getInstance().setPresenceStateListener(listener)if (!BiqController.getInstance().areAllPermissionsGranted()) {
val missingPermission = BiqController.getInstance().getMissingPermission()
// Request this permission from the user
}BiqController.getInstance().initNotificationData(
iconResId = R.drawable.ic_notification, // Optional
scanningNotificationTitle = "Scanning...",
scanningNotificationMessage = "Looking for beacons nearby",
proximityNotificationTitle = "Beacon detected!",
proximityNotificationMessage = "Presence has been validated"
)lifecycleScope.launch {
val records = BiqController.getInstance().loadDebugValidationRecords()
// Use these to display presence history
}BiqController.getInstance().removeDebugValidationRecords()lifecycleScope.launch {
val records = BiqController.getInstance().getValidationRecords()
// Process records
}.setNotificationEntryPoint(this::class.java)sets the Activity that will open when the user taps the presence notification..setBootAutoScan(true)will throw an exception ifRECEIVE_BOOT_COMPLETEDis not declared in the manifest.- Debug mode is only active in debug builds (
BuildConfig.DEBUG == true).
- AltBeacon (for beacon scanning)
For issues or feature requests, please contact BIQ Support.