Initialize the SDK
You must initialize the adjoe SDK before you can use any of its features. To do this, call Adjoe.Init(string, Action, Action<Exception>) 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 Action parameters which you pass.
After one successful initialization all following calls to Adjoe.Init will immediately invoke the error callback until your app is removed from the heap.

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 comopnent's OnApplicationPause method.

Example

1
using io.adjoe.sdk;
2
3
public class Main {
4
5
void Start()
6
{
7
Adjoe.Init("sdkHash", options, AdjoeInitialisationSuccess, AdjoeInitialisationError);
8
}
9
10
public void AdjoeInitialisationSuccess()
11
{
12
// the adjoe SDK was initialized successfully
13
}
14
15
public void AdjoeInitialisationError(Exception exception)
16
{
17
// an error occurred while initializing the adjoe SDK.
18
// note that exception might be null
19
}
20
21
}
Copied!
The parameters to this call are as follows:
The parameters to this call are as follows:
    string apiKey: Your adjoe API key.
    AdjoeOptions options: An object to pass additional options to the adjoe SDK when initializing. This parameter is optional and you can call Adjoe.Init(string) or Adjoe.Init(string, Action, Action<Exception>) instead.
    Action successCallback: A listener which is called when the adjoe SDK was initialized successfully. This parameter is optional and you can call Adjoe.Init(string) or Adjoe.Init(string, AdjoeOptions) instead.
    Action<Exception> errorCallback: A listener which is called when the initialization of the adjoe SDK failed. If it failed with an exception, this exception is passed as the first argument. This parameter is optional and you can call Adjoe.Init(string) or Adjoe.Init(string, AdjoeOptions) instead.
You can create an AdjoeOptions object in the following way:
1
AdjoeOptions options = new AdjoeOptions()
2
.SetUserId(userId);
Copied!
    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. 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
1
AdjoeParams adjoeParams = new AdjoeParams();
2
adjoeParams.SetUaNetwork("network")
3
.SetUaChannel("Channel")
4
.SetUaSubPublisherCleartext("SubPublisherCleartext")
5
.SetUaSubPublisherEncrypted("SubPublisherEncrypted")
6
.SetPlacement("placement");
7
AdjoeOptions options = new AdjoeOptions()
8
.SetUserId(userId);
9
.SetAdjoeParams(adjoeParams);
10
Adjoe.Init(sdkHash, options, AdjoeInitialisationSuccess, AdjoeInitialisationError);
Copied!

The IsInitialized method

To check whether the SDK is initialized you can call Adjoe.IsInitialized(). This will return true if the SDK is initialized and false otherwise. However, you should not condition calling Init on the result of IsInitialized because 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:
1
void Start() {
2
if (!Adjoe.IsInitialized()) {
3
Adjoe.Init(sdkHash, options, successCallback, errorCallback);
4
}
5
}
Copied!
Instead, just call Init without checking for IsInitialized. You can however use IsInitialized e.g. for debugging or to check whether the SDK is initialized before calling other methods of the SDK like RequestRewards.
Last modified 7mo ago
Copy link
Contents
Example