Edit in GitHubLog an issue

SDK Events

Description#

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.

Events#

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

NameArgumentsDescription
onDeviceDecisioningReadyNoneCalled only once the first time the client is ready for on-device decisioning
artifactDownloadSucceededbyte[] contents of artifact fileCalled every time a on-device decisioning artifact is downloaded
artifactDownloadFailedExceptionCalled every time there is a failure to download a on-device decisioning artifact

Example#

Copied to your clipboard
1ClientConfig clientConfig = ClientConfig.builder()
2 .client("acmeclient")
3 .organizationId("1234567890@AdobeOrg")
4 .defaultDecisioningMethod(DecisioningMethod.ON_DEVICE)
5 .onDeviceDecisioningHandler(new OnDeviceDecisioningHandler() {
6 @Override
7 public void onDeviceDecisioningReady() {
8 // make getOffers requests
9 makeTargetRequests();
10 }
11
12 @Override
13 public void artifactDownloadSucceeded(byte[] artifactData) {
14 System.out.println("The artifact was successfully downloaded.");
15 }
16
17 @Override
18 public void artifactDownloadFailed(TargetClientException e) {
19 System.out.println("The artifact failed to download.");
20 }
21 }).build();
22
23TargetClient targetJavaClient = TargetClient.create(clientConfig);
24
25
26void makeTargetRequests() {
27 List<MboxRequest> mboxRequests = new ArrayList<>();
28 mboxRequests.add((MboxRequest) new MboxRequest().name("a1-serverside-ab").index(1));
29
30 TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder()
31 .context(new Context().channel(ChannelType.WEB))
32 .execute(new ExecuteRequest().setMboxes(mboxRequests))
33 .build();
34
35 TargetDeliveryResponse targetResponse = targetJavaClient.getOffers(targetDeliveryRequest);
36}
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.