Skip to main content

Core Callbacks

Core callbacks as sent on core events, like on SDK Initialisation, User Identification, Event Tracking, Reward Received .

In order to integrate Core 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

class YourClass : NudgeGlobalCallback {
init{
NudgeGlobalCallbackManager.registerListener(this)
}
override fun onEvent(event: NudgeCallback) {
when (event){
is NudgeCoreCallback ->{
when (event.action){
"NUDGE_INITIALISED"->{
Log.d("Story From Nudge",event.DATA)
}
}
}
is NudgeUICallback -> {
when (event.action){
NCM.NUDGE_COMPONENT_CTA_CLICK.name->{
Log.d("CTA CLICK FROM NUDGE",event.action)
Log.d("NUDGE CALLBACK",event.data.toString())
}
NCM.NUDGE_EXPERIENCE_OPEN.name->{
Log.d("NUDGE CALLBACKE",event.data.toString())
}
NCM.NUDGE_EXPERIENCE_DISMISS.name->{
Log.d("NUDGE CALLBACKE",event.data.toString())
}
}
}
}
}
}

Removing Listener

You must remove the callback listener, on the destory of the class.

NudgeGlobalCallbackManager.unregisterListener(this)

Callback Name and Data

CallbackActionData Structure
NUDGE_CORE_CALLBACKNUDGE_INITIALISED{ sdk_version: string }
NUDGE_USER_IDENTIFIER_SUCCESS{ user_details: { name: string, email: string, phone_number: string, external_id: string } }
NUDGE_USER_IDENTIFIER_FAILURE{ user_details: { name: string, email: string, phone_number: string, external_id: string }, error: string, message: string }
NUDGE_TRACK_EVENT{ event: string, response: object }
NUDGE_REWARD_RECEIVED{ rewards: object[] }