Application Initialization
Bubbl must be initialized once at app startup.
Step 1: Create a custom Application class
File: app/src/main/java/.../MyApplication.kt
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize Firebase first
if (FirebaseApp.getApps(this).isEmpty()) {
FirebaseApp.initializeApp(this)
}
// Initialize Bubbl
BubblSdk.init(
application = this,
config = BubblConfig(
apiKey = "YOUR_API_KEY",
environment = Environment.PRODUCTION,
segmentationTags = emptyList(),
geoPollInterval = 5 * 60_000L,
defaultDistance = 10
)
)
}
}
Why this order matters
- Firebase must be ready before the SDK registers for notifications.
- Bubbl needs an
Applicationcontext because it lives across activities.
Optional: dynamic API key storage
For QA or multi-tenant test builds, you can load the API key at runtime instead of hardcoding it.
TenantConfigStore.load(this)?.let { cfg ->
BubblSdk.init(
application = this,
config = TenantConfigStore.toBubblConfig(cfg)
)
}
Tooltip
If you have a fixed API key, you can hardcode it and skip TenantConfigStore entirely.