Locations & Geofences

Geofences are only available in select Braze packages. For access please create a support ticket or speak with your Braze Customer Success Manager. Learn more in the Braze Academy.

To support geofences for Android:

  1. Your integration must support background push notifications.

  2. Braze location collection must not be disabled.

Braze location collection is enabled by default. To verify your location collection status on Android, ensure that com_appboy_disable_location_collection is not set to true in your appboy.xml.

Step 1: Update build.gradle

Add the Google Play Services Location package to your app level build.gradle using the Google Play Services setup guide:

dependencies {
  compile "com.google.android.gms:play-services-location:${PLAY_SERVICES_VERSION}"

See our sample application’s build.gradle for an example implementation.

Step 2: Update the Manifest

Add fine location permissions and boot permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

Add the Braze boot receiver to the application element of your AndroidManifest.xml:

<receiver android:name="com.appboy.AppboyBootReceiver">
    <action android:name="android.intent.action.BOOT_COMPLETED" />

Step 3: Obtain Location Permissions from the End User

For Android M and higher versions, you must request location permissions from the end user before gathering location information or registering geofences.

Add the following call to notify Braze when a user grants the location permission to your app:


This will cause the SDK to request geofences from Braze’s servers and initialize geofence tracking.

See RuntimePermissionUtils.java in our sample application for an example implementation.

Step 4: Enable Geofences on the Dashboard

Android only allows up to 100 geofences to be stored for a given app. Braze’s Locations product will use up to 20 of these geofence slots if available. To prevent accidental or unwanted disruption to other geofence-related functionality in your app, location geofences must be enabled for individual Apps on the Dashboard.

For Braze’s Locations product to work correctly, you should also ensure that your App is not using all available geofence spots.

Enable geofences from the Locations page:

Braze Developer Console

Enable geofences from the App Settings page:

Braze Developer Console

Note about Push to Sync

Note that Braze syncs geofences to devices using background push. In most cases this will involve no code changes, as this feature requires no further integration on the part of the app.

However, note that if your application is stopped, receiving a background push will launch it in the background and its Application.onCreate() method will be called. If you have a custom Application.onCreate() implementation, you should defer automatic server calls and any other actions you would not want triggered by background push.