Create and update dynamic, real-time notifications on Android devices using OneSignal Live Notifications. Deliver continuously updated content inside a single notification, simulating iOS Live Activities for Android.
Use this file to discover all available pages before exploring further.
OneSignal’s Android Live Notifications let you send real-time updates to a single notification, reducing clutter and improving engagement. These notifications remain persistent and update their content dynamically—ideal for sports scores, download progress, or event tracking.To receive Live Notifications, Android users must have push notifications enabled.
Unlike regular push notifications, which send a new notification each time, Live Notifications use a single notification updated over time. Updates are sent via the Create Message API using the same collapse_id.
Create a NotificationServiceExtension class that implements INotificationServiceExtension. This class intercepts incoming notifications and can modify or override them.
When designing a Live Notification, you have the flexibility to create a notification design for each update type. Each design you create must be assigned a specific type, allowing for varied presentations of a Live Notification.
NotificationServiceExtention.kt
private fun updateProgressNotification( liveNotificationUpdates: JSONObject, context: Context, notificationManager: NotificationManager ) { val currentProgress = liveNotificationUpdates.optInt("current_progress", 0) val builder = NotificationCompat.Builder(context, PROGRESS_CHANNEL_ID) .setContentTitle("Progress Live Notifications") .setContentText("It's working...") .setSmallIcon(android.R.drawable.ic_media_play) .setLargeIcon(BitmapFactory.decodeResource(context.resources, android.R.drawable.ic_dialog_info)) .setOngoing(true) .setOnlyAlertOnce(true) .setProgress(100, currentProgress, false) .setAutoCancel(false) // Prevent auto-dismissal of notification until you set the end event notificationManager.notify(keyMap[PROGRESS_LIVE_NOTIFICATION]!!, builder.build()) logger.info("Updated progress notification with progress: $currentProgress") }
Set event_attributes to initialize the static data for the Live Notification. This data will not change during the lifetime of the Live Notification.
Set event_updates data to initialize the dynamic data for the Live Notification. This is the data that can and will change during the lifetime of the Live Notification.
A collapse_id to make sure each update overrides the previous. This ID should be unique to the Live Notification to ensure subsequent updates are reflected in the same notification.
You can update the Live Notification as many times as you like, so long as it’s started first.
Set event_updates data to initialize the dynamic data for the Live Notification. This is the data that can and will change during the lifetime of the Live Notification and informs what to update your Live Notification’s content with.