Skip to content

3 - Add X3M SDK and MetaMediation adapters to your app

Cocoapods

We recommend using Cocoapods to integrate the SDK. Open your Podfile and add this line at the beginning:

source 'https://github.com/x3mads/podspecs.git'

You will also need to add the following line inside your app's target:

pod 'XMediator'
pod 'XMediatorObjC'

Finally, run from the command line:

pod install --repo-update

Choose Mediators and Networks

Use the following tool generate compatible dependencies for the Networks and Mediation SDKs of your choice:

Initialize the SDK

Before requesting any ad, make sure to call XMediatorAds.startWith(). This method configures your application Key, and fetches the required configuration parameters for the ad placements in your app, among other things.

Additionally, you may want to wait for the initialization callback to complete. This will ensure that your placement' requests have the necessary prebid configurations.

import XMediator

let userProperties = UserProperties(userId: "<an-optional-unique-user-id>")
let initSettings = InitSettings(userProperties: userProperties)
XMediatorAds.startWith(appKey: "<your-app-key>",
                       initSettings: initSettings) { result in
    print("Initialization complete! You can start loading your placements!")
}
@import XMediatorObjC;

X3MUserProperties *userProperties = [X3MUserProperties new];
userProperties.userId = @"<an-optional-unique-user-id>";

X3MInitSettings *initSettings = [X3MInitSettings new];
initSettings.userProperties = userProperties;

[X3MXMediatorAds startWithAppKey:@"<your-app-key>"
                    initSettings:initSettings
                        callback:^(NSError * _Nullable error) {
    NSLog(@"Initialization complete! You can start loading your placements!");
}];

Warning

To ensure the SDK is correctly configured before ad mediation begins, any method that performs an ad request will raise an exception if they are called before XMediatorAds.startWith() is invoked.

It is mandatory to wait for the init callback to complete before making any ad request.