Ui Callbacks
Ui callbacks as sent on Users's Interaction with any of Nudge's Experiences. This Includes actions like Clicks, Seen and Dismiss.
In order to integrate Ui Callbacks follow these steps:
Add Callback Listener
Extend the class in which you want to Listen the Callback with NudgeGlobalCallback
and register the class for receiving the callback by passing the instance of the class to NudgeGlobalCallbackManager
's registerListener
method.
Now by overriding the onEvent
method you can listen to the callbacks
public class YourClass: NudgeGlobalCallback {
var callbackManager = NudgeGlobalCallbackManager.shared
init() {
callbackManager.registerListener(self)
}
public func onEvent(event: NudgeCallback) {
switch event {
case let uiEvent as NudgeUICallback:
// Handle NudgeUICallback
let action = uiEvent.action
let data = uiEvent.data
// Perform logic based on the action/data here
default:
// Handle any other (perhaps unexpected) NudgeCallback subclasses
break
}
}
}
Removing Listener
You must remove the callback listener, on the destory of the class.
callbackManager.unregisterListener(self)
Callback Name and Data
Callback | Action | Data Structure |
---|---|---|
NUDGE_UI_CALLBACK | NUDGE_EXPERIENCE_OPEN | {CAMPAIGN_ID : string, CAMPAIGN_NAME : string, DISPLAY_NAME: string, DISPLAY_TYPE : string, DISPLAY_ID: string} |
NUDGE_EXPERIENCE_DISMISS | {CAMPAIGN_ID : string, CAMPAIGN_NAME : string, DISPLAY_NAME: string, DISPLAY_TYPE : string, DISPLAY_ID: string}} | |
NUDGE_EXPERIENCE_HIDDEN | { ... } | |
NUDGE_COMPONENT_CTA_CLICK | {TARGET: string, CAMPAIGN_ID: string, CAMPAIGN_NAME: string, WIDGET_NAME: string, WIDGET_ID: string, DISPLAY_NAME: string, CLICK_TYPE: string, DISPLAY_ID: string} |