ILiveUpdateStyleProvider
Interface your app implements to choose the notification style for each Live Update, for example NotificationCompat.ProgressStyle. Pass it to the LiveUpdatePlugin constructor.
Interface Definition
Package com.adobe.marketing.mobile.messaging.liveupdate.
fun interface ILiveUpdateStyleProvider {
fun provideStyle(payload: LiveUpdatePayload): NotificationCompat.Style?
}
Methods
provideStyle
Called once for each Live Update the plugin posts, after your interceptor and the SDK's validation.
Parameters
- payload: The LiveUpdatePayload being posted. Read your app-defined keys from
payload.contentState.
Returns
The NotificationCompat.Style to apply. When it returns null, the plugin posts the notification without a style and reports a style_null diagnostic event.
provideStyle runs on the FCM background thread, so do not perform long-running work in it.
Example
ILiveUpdateStyleProvider has a single method, so in Java you can also pass a lambda.
data-slots=heading, code
data-repeat=2
data-languages=Kotlin, Java
Kotlin
class MyLiveUpdateStyleProvider : ILiveUpdateStyleProvider {
override fun provideStyle(payload: LiveUpdatePayload): NotificationCompat.Style? {
return when (payload.contentState?.optString("custom_key_template_type")) {
"progress" -> NotificationCompat.ProgressStyle()
.setProgress(payload.contentState?.optInt("custom_key_progress", 0) ?: 0)
else -> null
}
}
}
Java
ILiveUpdateStyleProvider styleProvider = payload -> {
JSONObject contentState = payload.getContentState();
if (contentState != null
&& "progress".equals(contentState.optString("custom_key_template_type"))) {
return new NotificationCompat.ProgressStyle()
.setProgress(contentState.optInt("custom_key_progress", 0));
}
return null;
};