SDK Events (Java)

Last update: 2023-07-17
  • Created for:
  • Developer


When initializing the SDK, an optional OnDeviceDecisioningHandler object can be provided on the ClientConfig object. It can be used to subscribe to various events that occur within the SDK. For instance, the onDeviceDecisioningReady event may be used with a callback function that will be invoked when the SDK is ready for method calls.


The OnDeviceDecisioningHandler object contains the following callbacks, which are called for certain events:

Name Arguments Description
onDeviceDecisioningReady None Called only once the first time the client is ready for on-device decisioning
artifactDownloadSucceeded byte[] contents of artifact file Called every time a on-device decisioning artifact is downloaded
artifactDownloadFailed Exception Called every time there is a failure to download a on-device decisioning artifact


SDK Events

ClientConfig clientConfig = ClientConfig.builder()
        .onDeviceDecisioningHandler(new OnDeviceDecisioningHandler() {
            public void onDeviceDecisioningReady() {
                // make getOffers requests

            public void artifactDownloadSucceeded(byte[] artifactData) {
                System.out.println("The artifact was successfully downloaded.");

            public void artifactDownloadFailed(TargetClientException e) {
                System.out.println("The artifact failed to download.");

TargetClient targetJavaClient = TargetClient.create(clientConfig);

void makeTargetRequests() {
    List<MboxRequest> mboxRequests = new ArrayList<>();
    mboxRequests.add((MboxRequest) new MboxRequest().name("a1-serverside-ab").index(1));

    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder()
            .context(new Context().channel(ChannelType.WEB))
            .execute(new ExecuteRequest().setMboxes(mboxRequests))

    TargetDeliveryResponse targetResponse = targetJavaClient.getOffers(targetDeliveryRequest);

On this page