Skip to Content

Android SDK — Advanced

Beyond core tracking, the Android SDK handles FCM tokens, deep links, notification channels, and background resilience.

FCM token management

Automatic token registration via Firebase:

FirebaseMessaging.getInstance().token.addOnSuccessListener { token -> Aegis.push.registerDeviceToken(token) }

Handle token refresh in your FirebaseMessagingService:

class MyFirebaseService : FirebaseMessagingService() { override fun onNewToken(token: String) { Aegis.push.registerDeviceToken(token) } override fun onMessageReceived(message: RemoteMessage) { Aegis.push.trackDelivery(messageId = message.messageId ?: "") } }

Deep linking

Handle Active Reach deep links in your activity:

override fun onNewIntent(intent: Intent?) { super.onNewIntent(intent) intent?.data?.let { uri -> if (Aegis.handleDeepLink(uri)) return // Your own deep link handling } }

Notification channels (Android 8+)

The SDK creates a default notification channel on initialization. Customize it:

Aegis.init(this, "YOUR_WRITE_KEY", AegisConfig( workspaceId = "YOUR_WORKSPACE_ID", pushChannelId = "promotions", pushChannelName = "Promotions", pushChannelImportance = NotificationManager.IMPORTANCE_HIGH, ))

Background tracking

For tracking events when the app is in the background (e.g., geofence triggers):

// Call from a WorkManager or background service Aegis.track("geofence_entered", mapOf("location" to "Store A")) Aegis.flush() // Flush immediately in background

Always call flush() after background events — the SDK’s batch timer doesn’t run in the background.

Offline mode

Same as iOS — events cached locally when offline, flushed on connectivity return. Max 1,000 events by default.

What’s next