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, Object) when your app is starting, for example in your App.js's componentDidMount() method. The init method will return a promise which resolves when the SDK has been initialized successfully and rejects with an optional error parameter when an error occurred during the initialization. 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 componentDidMount method.

Example

1
Adjoe.init('sdkHash', { 'user_id': getUserId() })
2
.then(() => {
3
console.log('Initialized adjoe SDK');
4
})
5
.catch((err) => {
6
console.log('Could not initilize adjoe SDK');
7
console.error(err);
8
});
Copied!
The parameters to this call are as follows:
    String sdkHash: Your adjoe API key.
    Object options: An object to pass additional options to the adjoe SDK when initializing. See below for a detailed description of the available options. This object is optional and you can leave it out or pass null or an empty object.
You can set the following parameters in the options object:
    String user_id: 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().
    { } adjoeParams: A holder of User Acquisition parameters and offerwall placement.
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
Adjoe.init('sdkHash', {
2
'user_id': getUserId(),
3
'adjoeParams': {
4
'uaNetwork': "uaNetwork_value",
5
'uaChannel': "uaChannel_value",
6
'uaSubPublisherCleartext': "uaSubPublisherCleartext_value",
7
'uaSubPublisherEncrypted': "uaSubPublisherEncrypted_value",
8
'placement': 'placement_value'
9
}
10
}).then(() => {
11
console.log('Initialized adjoe SDK');
12
})
13
.catch((err) => {
14
console.log('Could not initilize adjoe SDK');
15
console.error(err);
16
});
Copied!
Last modified 7mo ago
Copy link
Contents
Example