Braze Android Integration

Table of Contents

  • Getting Started
  • Integrate Bluedot Point SDK in your Project
  • Interaction between Braze SDK and Bluedot Point SDK

Getting Started

1. Modify your build.gradle to include Braze SDK.

repositories {
    maven { 
        url "" 

Braze supports a few push providers: FCM, GCM, ADM. We recommend using Firebase. However, you can choose other.

2. In the app gradle add

implementation "com.appboy:android-sdk-ui:+"

3. Create appboy.xml under the res folder and add the following code. Create a Braze Android App and get the API key and replace it in the “REPLACE_WITH_YOUR_API_KEY”. Also, replace the “YOUR_CUSTOM_ENDPOINT_OR_CLUSTER” with the custom endpoint from Braze.

<?xml version="1.0" encoding="utf-8"?>
    <string name="com_appboy_api_key">REPLACE_WITH_YOUR_API_KEY</string>
    <string translatable="false" name="com_appboy_custom_endpoint">YOUR_CUSTOM_ENDPOINT_OR_CLUSTER</string>
    <bool translatable="false" name="com_appboy_firebase_cloud_messaging_registration_enabled">true</bool>
    <string translatable="false" name="com_appboy_firebase_cloud_messaging_sender_id">your_fcm_sender_id_here</string>
    <integer name="com_appboy_default_notification_accent_color">0xFFf33e3e</integer>
    <bool name="com_appboy_handle_push_deep_links_automatically">true</bool>

4. In the AndroidManifest.xml add the following:
a. The following permissions are required.

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

b. The following braze service should be included to handle push receipt and open intents.

<service android:name="com.appboy.AppboyFirebaseMessagingService">
        <action android:name="" />


Integrate Bluedot Point SDK in your Project

To integrate Bluedot Point SDK in your project, please click here


Interaction between Braze SDK and Bluedot Point SDK

1. We need to ask the user to give permission to use the location services. To do that, create a RequestPermissionActivity.kt and then add the below code.

override fun onCreate(savedInstanceState: Bundle?) {

    //Request permission required for location
        arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION),

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    when (requestCode) {
        PERMISSION_REQUEST_CODE -> if (grantResults.size > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            (application as MainApplication).initPointSDK()

        } else {
            //Permissions denied


2. We then create another class which will implements Bluedot InitializationResultListener and upon SDK initialisation, calls Braze’s changeUser API. To do that create MainApplication.kt class and add the below code.

class MainApplication : Application(), InitializationResultListener {

    private lateinit var mServiceManager: ServiceManager
    private val projectId = Bluedot Project Id for the App

    override fun onCreate() {

        registerActivityLifecycleCallbacks(AppboyLifecycleCallbackListener(false, false))

        // initialize Bluedot point sdk

    fun initPointSDK() {
        val checkPermissionFine = 
            ActivityCompat.checkSelfPermission( applicationContext, Manifest.permission.ACCESS_FINE_LOCATION ) 

        if (checkPermissionFine == PackageManager.PERMISSION_GRANTED) { 
            mServiceManager = ServiceManager.getInstance(this) 
            if (!mServiceManager.isBluedotServiceInitialized) { 
                mServiceManager.initialize(projectId, this) 
        } else { 

    private fun requestPermissions() {
        val intent = Intent(applicationContext,
        intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK

This method is called when BlueDotPointService started successfully, your app logic code using the Bluedot service could start from here. Replace “YOUR_BRAZE_USER_ACCOUNT” with the Braze user account.

    override fun onInitializationFinished(error: BDError?) {
        if (error != null) {
                "Bluedot Point SDK initialization error: ${error.reason}",

        println("Bluedot Point SDK authenticated")

3. Next, we create a class which will receive Bluedot GeoTrigger events, which we will then log the event via the Braze API. To do that create BluedotGeoTriggerReceiver.kt class and add the below code.

class BluedotGeoTriggerReceiver: GeoTriggeringEventReceiver() {
    private val customEventEntry = YOUR CUSTOM ENTRY EVENT NAME
    private val customEventExit =YOUR CUSTOM EXIT EVENT NAME

    override fun onZoneEntryEvent(entryEvent: ZoneEntryEvent, context: Context) {
        println("Zone ${entryEvent.zoneInfo.zoneName}, fence ${} entered at: ${Date()}")

        val eventProperties = AppboyProperties()
        eventProperties.addProperty("zone_id", entryEvent.zoneInfo.zoneId)
        eventProperties.addProperty("zone_name", entryEvent.zoneInfo.zoneName)
        eventProperties.addProperty("latitude", entryEvent.locationInfo.latitude)
        eventProperties.addProperty("longitude", entryEvent.locationInfo.longitude)

        entryEvent.zoneInfo.getCustomData()?.forEach { data ->
            eventProperties.addProperty(data.key, data.value)

        Appboy.getInstance(context).logCustomEvent(customEventEntry, eventProperties)

    override fun onZoneExitEvent(exitEvent: ZoneExitEvent, context: Context) {
        println("Zone ${exitEvent.zoneInfo.zoneName}, fence ${} exited at: ${Date()}")

        val eventProperties = AppboyProperties()
        eventProperties.addProperty("zone_id", exitEvent.zoneInfo.zoneId)
        eventProperties.addProperty("zone_name", exitEvent.zoneInfo.zoneName)
        eventProperties.addProperty("dwellTime", exitEvent.dwellTime)

        exitEvent.zoneInfo.getCustomData()?.forEach { data ->
            eventProperties.addProperty(data.key, data.value)

        Appboy.getInstance(context).logCustomEvent(customEventExit, eventProperties)

    override fun onZoneInfoUpdate(zones: List<ZoneInfo>, context: Context) {
        println("Zones updated at: ${Date()} \nZoneInfos count: ${zones.count()}")
Created by Ram Akunuru on August 6, 2019