Add Beacons

1. Add AltBeacon and Google Play Service Location Dependency to your build

To be compatible with the current version of the SDK, replace {currentBeaconVersion} with 2.20, and replace {currentLocationVersion} with 21.0.1. These versions have been tested with the latest version of the SDK. Behavior is not guaranteed if you use a different version of either dependency.

2. Add these permissions to your application’s AndroidManifest.xml

3. Enable beacon messaging during SDK initialization

To troubleshoot information related to beacons in the InitializationStatus that is returned during the SDK’s initialization call, see initialization status documentation.

4. Request permissions

  • Location permissions

    To enable proximity messaging, request the required location permissions from your users at runtime. For users on devices running Android Q, request both the ACCESS_FINE_LOCATION and ACCESS_BACKGROUND_LOCATION permissions. For users on devices older than Android Q, you can request only the ACCESS_FINE_LOCATION permission.

  • Bluetooth permission

    To enable proximity messaging, request the required location permissions from your users at runtime. For users on devices running Android S and above, request the BLUETOOTH_SCAN permission.

See Request App Permissions for more information on requesting runtime permissions. See Android Q privacy change documentation for more information on location permission change.

5. Enable beacon messaging at runtime

Once all the permissions are granted you can enable beacon notification by calling enableProximityMessaging().

You can disable beacon notifications by calling disableProximityMessaging().

MobilePush prevents the app from displaying a beacon message with an empty alert. If you include AMPscript in your message that returns no content or an empty string, the mobile app will not display that message.

To understand how beacons behave in different situations, see the MobilePush beacons help documentation.

Add Debug Logging for Beacons

Proximity logging is off by default. To turn it on, use AltBeacon’s LogManager class. Our AltBeacon Logger implementation sends their logs through our internal logging interface. Use the following example code as a guide.