Start Live Updates
Once you’ve set up Live Updates, there are two ways to start a live notification:
- From your server: You call the API when you’re ready to start a live notification, and Customer.io delivers an FCM data message. The SDK renders the notification without your app needing to be open. This is the most common path for notifications like delivery tracking and live scores.
- From your app: Start the notification locally through the push module. Built-in types use typed data classes; custom types take a field map. This is a common path for notifications like a workout progress tracker.
From your server
Call the API to start and update a live notification. Customer.io delivers the FCM data message, and the SDK renders the notification from your payload’s fields. See the API and payload reference for each template’s fields.
From your app
Start the notification locally through the push module:
import io.customer.messagingpush.livenotification.LiveNotificationData
// Built-in template type
val activityId = pushModule.startLiveNotification(
LiveNotificationData.Segments(
header = "Order",
status = "Order received",
segmentsTotal = 4,
segmentsComplete = 1
)
)
startLiveNotification returns the notification’s generated ID and registers it with Customer.io, so your server can take over updates from there. Local starts and ends are reported to Customer.io automatically. Local updates change the notification on the device but don’t appear in the Customer.io delivery timeline.
Then you can update the notification and end it later with the returned ID:
// Update and end it later with the returned id
pushModule.updateLiveNotification(
activityId,
LiveNotificationData.Segments(
header = "Order",
status = "Out for delivery",
segmentsTotal = 4,
segmentsComplete = 3
)
)
pushModule.endLiveNotification(activityId)
For the full lifecycle, states, instance IDs, and how deliveries appear in Customer.io, see the API and payload reference.
How the SDK handles tokens and updates
Live Updates reuse the FCM registration token your app already uses for push. There are no separate token types to manage. The SDK registers tokens for identified people only—if a customer hasn’t been identified yet, it holds the registration and sends it when they are.
Live notifications arrive as FCM data messages, not display notifications, so the SDK renders them directly and updates the notification in place by its instance ID. Because Android renders each message as it arrives, the SDK guards against out-of-order and duplicate deliveries using the message timestamp.
Two things end a notification’s lifecycle on the device beyond your server’s end call:
- A person dismisses the notification. When someone swipes the notification away, the SDK ends the activity and clears it.
- A person logs out. The SDK ends and clears every live notification on the device.