ILiveUpdateInterceptor
Interface your app implements to decide, from its own state, whether an incoming Live Update is shown. Register it with setLiveUpdateInterceptor. Only one interceptor is active at a time.
Interface Definition
Package com.adobe.marketing.mobile.messaging.liveupdate.
interface ILiveUpdateInterceptor {
fun shouldDisplayLiveUpdate(payload: LiveUpdatePayload): Boolean
}
Methods
shouldDisplayLiveUpdate
Called after the push is parsed and before any other processing, for pushes the plugin renders and for triggerLocalLiveUpdate. It is not called in manual mode.
Parameters
- payload: The parsed LiveUpdatePayload.
Returns
true to let the SDK proceed; false to drop the Live Update. A dropped Live Update is not posted, sends no tracking event, calls no listener callback, and is reported as an app_discarded diagnostic event.
When no interceptor is registered, or the interceptor throws an exception, the Live Update proceeds. shouldDisplayLiveUpdate runs on the FCM background thread, so keep the decision fast.
Example
data-slots=heading, code
data-repeat=2
data-languages=Kotlin, Java
Kotlin
LiveUpdates.setLiveUpdateInterceptor(object : ILiveUpdateInterceptor {
override fun shouldDisplayLiveUpdate(payload: LiveUpdatePayload): Boolean {
// Custom logic to discard any Live Update that this device was not supposed to receive.
// Return false to drop this Live Update, or true to let the SDK proceed.
return shouldShowLiveUpdate(payload)
}
})
Java
LiveUpdates.setLiveUpdateInterceptor(payload -> {
// Custom logic to discard any Live Update that this device was not supposed to receive.
// Return false to drop this Live Update, or true to let the SDK proceed.
return shouldShowLiveUpdate(payload);
});
For typical reasons to drop a Live Update, see Suppress updates with an interceptor.