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 after your app authentication: You should initialize the SDK (again) with up-to-date details as soon as your user has signed up/signed in to the app so to update the userId.

  • 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

If you utilize the "user_id" parameter, ensure it never has an empty value.

// General idea
Adjoe.init('sdkHash', options).then(/* sucess */).catch(/* fail */);
// A complete example
Adjoe.init('sdkHash', 
    { 
      'user_id': "06957070-6579-46cd-9665-d8fe7cd286d5",
      'applicationProcessName' : "io.adjoe.anyApp",
      'adjoeParams': {
                'uaNetwork': "uaNetwork_value",
          	'uaChannel': "uaChannel_value",
          	'uaSubPublisherCleartext': "uaSubPublisherCleartext_value",
          	'uaSubPublisherEncrypted': "uaSubPublisherEncrypted_value",
          	'placement': 'placement_value'
        }, 
        'adjoeExtension': {
                'subId1': "RN_subId1",
                'subId2': "RN_subId2",
                'subId3': "RN_subId3",
                'subId4': "RN_subId4",
                'subId5': "RN_subId5"
        }, 
        'adjoeUserProfile': {
                'gender': 'male',
                'birthday': "2023-07-17T22:25:00.000Z"
        }
    
    }).then(() => {
      console.log('Initialized adjoe SDK');
    })
    .catch((err) => {
      console.log('Could not initilize adjoe SDK');
      console.error(err);
    });

The parameters to this call are as follows:

  • String sdkHash: Your adjoe API key.

  • Object options: An map 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(). Only this ID will allow you to match the payouts to your users in the process of Server-to-server payout.

If you utilize the "user_id" parameter, ensure it never has an empty value.

  • String applicationProcessName: Numerous operations within the Adjoe SDK, including initialisation, only execute if the current process matches your application process name. If you manually adjust the android.process for the application tag in the AndroidManifest file, please ensure you also set it in the Adjoe SDK using the setter for this variable.

  • { } adjoeParams: A table containing additional User Acquisition and Playtime placement information.

  • { } AdjoeUserProfile: This contains the birthday and the gender of the user using the App. Using this adjoe can provide a more suitable advertising campaign for the user.

  • { } AdjoeExtensions: This object contains additional optional five string identifiers that i.e would have a meaning in your system and they will be provided back in the Server-to-server payout.

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