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

public class YourClass: NudgeGlobalCallback {

var callbackManager = NudgeGlobalCallbackManager.shared

init() {
callbackManager.registerListener(self)
}

public func onEvent(event: NudgeCallback) {
switch event {
case let coreEvent as NudgeCoreCallback:
// Handle NudgeCoreCallback
let action = coreEvent.action
let data = coreEvent.data
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

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: [String:Any] }
NUDGE_REWARD_RECEIVED{ rewards: [String:Any] }