Initialize the SDK

You need to initialize the adjoe SDK before you can use any of its features. To do this, call adjoe.init(String, Options) as early in your application lifecycle as possible. The initialization will run asynchronously in the background and notify you when it is finished by sending the onInitialisationFinished or onInitialisationError event. After one successful initialization all following calls to adjoe.init will immediately send the onInitialisationFinished event until your app is removed from the heap. The SDK initialization should be started as soon as possible after the app comes to foreground to make sure that all adjoe features are available when you want to use them.

Best practices for the SDK initialization:

  • Initialize early: You should initialize the SDK as soon as possible after your app starts to make sure that all adjoe features are available when you want to use them.

  • Initialize regularly: For the best user experience, we highly recommend to call this method every time your app comes to the foreground. This should not be noticeable in your app's performance.

  • Initialization triggers: Good places to call this method are the app start and your main component's constructor.

Example

import io.adjoe.sdk.AdjoeSDK;
import io.adjoe.sdk.Options;
import io.adjoe.sdk.AdjoeInitialisationEvent;

...

public function initializeAdjoe():void {
  var adjoe:AdjoeSDK = new AdjoeSDK();
  var options:Options = new Options();

  // If you already have an ID for your user, you should pass it to adjoe to receive all callbacks correctly.
  // If you don't have a user ID, omit the following line and the adjoe SDK will create a user ID.
  options.setUserId(userId);
  
  // It's recommended you add the Adjoe params to the option as follow:

  var adjoeParams:AdjoeParams = new AdjoeParams();
  adjoeParams.setUaNetwork("init-uaNetwork");
  adjoeParams.setUaChannel("init-UaChannel");
  adjoeParams.setUaSubPublisherCleartext("init-UaSubPublisherCleartext");
  adjoeParams.setUaSubPublisherEncrypted("init-UaSubPublisherEncrypted");
  adjoeParams.setPlacement("init-Placement");

  options.setAdjoeParams(adjoeParams);

  adjoe.addEventListener("onInitialisationFinished", onInitialisationFinished);
  adjoe.addEventListener("onInitialisationError", onInitialisationError);

  adjoe.init("<sdkHash>", options);
}

private function onInitialisationFinished(evt:AdjoeInitialisationEvent):void {
  trace("Adjoe initialisation was successful");
}

private function onInitialisationError(evt:AdjoeInitialisationEvent):void {
  trace("Adjoeinitialisation failed: " + evt.getErrorMessage());
}

The parameters to this call are as follows:

  • String apiKey: Your adjoe SDK hash.

  • Options options: An object to pass additional options to the adjoe SDK when initializing.

You can set the following parameters in the options object:

  • AdjoeParams params: A table containing User Acquisition and Playtime placement parameters.

  • String userId: A custom identifier that you wish to assign to this user. If you don't have an identifier for your user already, omit this parameter and the adjoe SDK will generate one. You can then access it by calling Adjoe.getUserId().

If you want to use S2S payout, you have to set the user id in order to match the payout to your user.

Adjoe Parameters

You can pass additional UA and placement parameters when you initialize the SDK

  var adjoeParams:AdjoeParams = new AdjoeParams();
  adjoeParams.setUaNetwork("init-uaNetwork");
  adjoeParams.setUaChannel("init-UaChannel");
  adjoeParams.setUaSubPublisherCleartext("init-UaSubPublisherCleartext");
  adjoeParams.setUaSubPublisherEncrypted("init-UaSubPublisherEncrypted");
  adjoeParams.setPlacement("init-Placement");

Last updated