Handling User Consent

The Nearby Messages API has the potential to be battery-intensive due to the way it uses Bluetooth and other device resources to detect and communicate with nearby devices. To ensure that users are in control of the experience, an opt-in dialog is presented the first time the user accesses the Nearby Messages API. The user must provide consent for Nearby to utilize the required device resources.

BLE Only

You can avoid the opt in dialog if your app has been granted the ACCESS_FINE_LOCATION permission and only uses BLE during publishes and subscribes.

if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
        == PackageManager.PERMISSION_GRANTED) {
    mMessagesClient = Nearby.getMessagesClient(this, new MessagesOptions.Builder()
            .setPermissions(NearbyPermissions.BLE)
            .build());
}

Send feedback about...

Nearby Messages API for Android
Nearby Messages API for Android