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.19, and replace {currentLocationVersion} with 17.1.0. 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 location permission

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.

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

5. Enable beacon messaging at runtime

Once the permission is 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.