B Bubbl Docs

Android Quickstart

This is the fastest route to a working native Android integration.

1) Ensure mavenCentral() is configured

In settings.gradle.kts:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
        google()
        mavenCentral()
    }
}

2) Add dependencies

In app/build.gradle.kts:

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("com.google.gms.google-services")
}

dependencies {
    implementation(platform("com.google.firebase:firebase-bom:33.3.0"))
    implementation("com.google.firebase:firebase-messaging-ktx")

    implementation("tech.bubbl.sdk:bubbl-sdk:2.3.7")

    implementation("com.google.android.gms:play-services-location:21.2.0")
    implementation("androidx.work:work-runtime-ktx:2.10.0")
}

3) Add manifest entries

In app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

<application android:name=".MyApplication">
  <service
      android:name="tech.bubbl.sdk.services.LocationUpdatesService"
      android:foregroundServiceType="location" />

  <service
      android:name="tech.bubbl.sdk.services.MyFirebaseMessagingService"
      android:exported="false">
      <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT" />
      </intent-filter>
  </service>

  <meta-data
      android:name="com.google.firebase.messaging.default_notification_channel_id"
      android:value="bubbl_push" />
</application>

4) Initialize in Application

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        if (FirebaseApp.getApps(this).isEmpty()) {
            FirebaseApp.initializeApp(this)
        }

        BubblSdk.init(
            application = this,
            config = BubblConfig(
                apiKey = "YOUR_API_KEY",
                environment = Environment.PRODUCTION,
                segmentationTags = emptyList(),
                geoPollInterval = 5 * 60_000L,
                defaultDistance = 10
            )
        )
    }
}

5) Request permissions and start tracking

val permMgr = PermissionManager(this)

permLauncher = permMgr.registerLauncher { granted ->
    if (granted) BubblSdk.startLocationTracking(this)
}

if (permMgr.locationGranted() && permMgr.notificationGranted()) {
    BubblSdk.startLocationTracking(this)
} else {
    permLauncher.launch(permMgr.requiredPermissions())
}

6) Refresh campaigns

BubblSdk.refreshGeofence(latitude, longitude)
BubblSdk.forceRefreshCampaigns()

Continue with Method Reference, Usage Examples, and Modal Styling.