What you will learn

This tutorial will teach you how to manage bluetooth permission with the mobile SDK.

Prerequisites - What you need to get started

  • Your SDK credentials, including an SDK Login, Password, and Company Key to initialize the SDK.
  • A BLE beacon, which has been configured on your account, in order to test interactions with your app.
  • An Android Device, with Bluetooth 4.0 and Android 4.0 and above, to be able to interact with BLE beacons.
  • The Android Studio application, which you can download from the Android Developers website.
  • You must have completed the location permission tutorial

About bluetooth permission

Our mobile SDK uses bluetooth scanning to detect nearby beacons, and has the ability to automatically enable bluetooth on smartphones. However, bluetooth is a critical function of smart devices, and has direct impact on battery consumption.

As such, you can configure the way the SDK accesses to this functionality on the App Settings section of the Adtag Platform depending of the application state (foreground or background).

When the application is on foreground, the Adtag Platform permits:

  • to automatically enable the bluetooth if disabled
  • or to let the bluetooth disabled

When the application is on background, the Adtag Platform permits:

  • to automatically enable the bluetooth if disabled
  • to let the bluetooth disable
  • to ask the permission to enable bluetooth the first time the bluetooth is disabled when the app is in background
    • In that case, the SDK displays a notification to the user

Customizing the asking permission notification

In the case the SDK asks the permission to enable the bluetooth when the application is in background, the SDK generates a notification the first time that it detects that the application is in the background, and that bluetooth has been disabled. You can customize the strings and the drawables of the notification.

In a strings.xml file, use the following keys to customize the strings associated with the notification:

  • notification_ble_bg_title: title of the notification
  • notification_ble_bg_desc: description field for the notification
  • notification_ble_btn_grant: label of the button to grant permission
  • notification_ble_btn_refuse: label of the button to refuse permission

In your drawable folders, you can add the following files to customize the drawables associated with the notification:

  • icon_notification_ble_ask_permission: icon associated with the notification
  • btn_notification_ble_grant: icon of the button to grant permission
  • btn_notification_ble_refuse: icon of the button to refuse permission