Initialize the SDK
You need to initialize the adjoe SDK before you can use any of its features. To do this, call
Adjoe.Init(sdkHash, options, success, failure). when your app is starting. The initialization will run asynchronously in the background and notify you when it is finished by invoking one of the callback methods. After one successful initialization all following calls to
Adjoe.Initwill immediately invoke the success callback until your app is removed from the heap. The SDK initialization should be started as soon as possible after the app starts to make sure that all adjoe features are available when you want to use them.
local Adjoe = class("Adjoe", cc.load("adjoe").Adjoe)
-- the adjoe plugin was initialized successfully
-- an error occurred while initializing the adjoe plugin.
The parameters to this call are as follows:
- String sdkHash: You adjoe API key.
- Table options: A table for passing additional values to the initialization of adjoe. Currently the following options are supported:
- String UserID: A custom identifier that you wish to assign to this user. If you don't have an identifier for your user already, the adjoe SDK will generate one.
- Table AdjoeParams: A table containing User Acquisition and Playtime placement parameters.
You can pass additional UA and placement parameters when you initialize the SDK
local params = Adjoe.NewAdjoeParams()
local options = Adjoe.NewOptions()
Adjoe.Init("sdkHash", options, success, failure)
To check whether the SDK is initialized you can call
Adjoe.IsInitialized(). This will return
trueif the SDK is initialized and
falseotherwise. However, you should not condition calling
Initon the result of
IsInitializedbecause the SDK will do some checks on its own. You should not do something like the following as it can lead to bad user experience:
if not Adjoe.IsInitialized() then
Adjoe.Init(sdkHash, options, successCallback, errorCallback);
Instead, just call
Initwithout checking for
IsInitialized. You can however use
IsInitializede.g. for debugging or to check whether the SDK is initialized before calling other methods of the SDK like