LiveUpdatePayload
The parsed Live Update data (adb_liveupdate_data). The SDK creates it when it parses a push and passes it to your ILiveUpdateStyleProvider, ILiveUpdateListener, and ILiveUpdateInterceptor. For what each key means, see Live Update payload.
Class Definition
Package com.adobe.marketing.mobile.messaging.liveupdate. The constructor is private: get an instance from parse, or build one with create for a local trigger.
Properties
notificationIdStringnotification_idchannelIdStringnotification_channel_idtimestampLongtimestamptitleString?titlebodyString?bodycriticalTextString?critical_textwhenSecondsLong?whendismissAfterSecondsLong?dismiss_afterend push before the notification is removed.priorityString?priorityPRIORITY_HIGH.topicNameString?topic_namecontentStateJSONObject?content_statexdmJSONObject?_xdmadb_liveupdate_data. The SDK copies it into tracking events.In Java, read each property with its getter, for example getNotificationId() or getContentState().
Constants
Values of eventType, available as static fields of LiveUpdatePayload:
EVENT_TYPE_START"start"EVENT_TYPE_UPDATE"update"EVENT_TYPE_END"end"EVENT_TYPE_LOCAL_START"localstart"Methods
parse
Parses an FCM message into a LiveUpdatePayload. Use it in manual mode.
fun parse(message: RemoteMessage): LiveUpdatePayload?
public static LiveUpdatePayload parse(RemoteMessage message)
Returns
The parsed payload, or null when the message has no adb_liveupdate_data key, the adb_liveupdate_data value is not valid JSON, or a required field (notification_id, notification_channel_id, event_type, timestamp) is missing.
isLiveUpdate
Returns true when the FCM message carries the adb_liveupdate_data key.
fun isLiveUpdate(message: RemoteMessage): Boolean
public static boolean isLiveUpdate(RemoteMessage message)
create
Builds a payload in your app, for triggerLocalLiveUpdate.
Parameters
- notificationId: Required. Identifies the Live Update.
- channelId: Required. Android notification channel to post on.
- eventType: Required. Use
EVENT_TYPE_LOCAL_STARTfor a local start. - title: Required, nullable. A title isn't mandatory, but some notification styles require one.
- timestamp: Required. The current time in epoch seconds. A value in epoch milliseconds is converted to seconds.
- priority, body, criticalText, whenSeconds, dismissAfterSeconds, contentState, topicName, xdm: Optional. Each defaults to
null. In Java, pass the arguments in this order, and passnullfor optional values you do not set.
Example
data-slots=heading, code
data-repeat=2
data-languages=Kotlin, Java
Kotlin
val payload = LiveUpdatePayload.create(
notificationId = "order_1234",
channelId = "live_updates_channel",
eventType = LiveUpdatePayload.EVENT_TYPE_LOCAL_START,
title = "Order on the way",
timestamp = System.currentTimeMillis() / 1000,
contentState = JSONObject().put("custom_key_template_type", "progress")
)
LiveUpdates.triggerLocalLiveUpdate(context, payload)
Java
JSONObject contentState = new JSONObject();
try {
contentState.put("custom_key_template_type", "progress");
} catch (JSONException e) {
// handle the error
}
LiveUpdatePayload payload = LiveUpdatePayload.create(
"order_1234", // notificationId
"live_updates_channel", // channelId
LiveUpdatePayload.EVENT_TYPE_LOCAL_START, // eventType
"Order on the way", // title
System.currentTimeMillis() / 1000, // timestamp
null, // priority
null, // body
null, // criticalText
null, // whenSeconds
null, // dismissAfterSeconds
contentState // contentState
);
LiveUpdates.triggerLocalLiveUpdate(context, payload);