Mediation

Initialize Mediation

Import Headers πŸ”—

Add the following import headers to the top of any class file that will be using a Mediation and Core class:

import ChartboostCoreSDK
import ChartboostMediationSDK

Network Kill Switch πŸ”—

The network kill switch is a static method ChartboostMediation.setPreinitializationConfiguration() that must be called before Core SDK initialization is initiated. This prevents specific partners from being initialized.

// Optionally set the Chartboost Mediation preinitialization configuration
// to disable some mediation partners.
ChartboostMediation.setPreinitializationConfiguration(
    .init(skippedPartnerIDs: YOUR_LIST_OF_PARTNER_IDS_TO_SKIP)
)
Partner Identifier
AdMob admob
Amazon Publisher Services amazon_aps
AppLovin applovin
BidMachine bidmachine
Chartboost Monetization chartboost
Digital Turbine Exchange (Fyber) fyber
HyprMX hyprmx
Google Bidding google_googlebidding
InMobi inmobi
ironSource ironsource
Liftoff Monetize (Vungle) vungle
Meta Audience Network facebook
Mintegral mintegral
MobileFuse mobilefuse
Pangle pangle
Unity unity
Verve verve

A Consent Management Platform (CPM) is required and handled by the Core SDK. Review the Core SDK’s Consent Management Platform documentation to set up your CPM module. Once a CPM is chosen and setup, initialize the module.

// Create a consent module instance, e.g. Usercentrics
let usercentrics = UsercentricsAdapter(
    options: .init(settingsId: "<YOUR USECENTRICS SETTINGS ID>")
)

Initialize Chartboost Core πŸ”—

Initializing Chartboost Core only requires your Chartboost App ID which initializes Mediation.

To find your Chartboost app ID, log into your Chartboost platform, navigate to Apps Management, select your app, and the app ID will be listed on the right column under App information.

// Initialize Core.
// This automatically initializes the Chartboost Mediation SDK, as well as other
// modules included in the `modules` array.
// Make sure to include your consent module in this array.
ChartboostCore.initializeSDK(
    configuration: .init(chartboostAppID: "<YOUR APP ID>"),
    modules: [usercentrics],
    moduleObserver: self  // optional observer, can be nil
)

ModuleObserver πŸ”—

The module observer notifies when the specified module finishes initialization so additional action can follow. This module is optional.

// Optionally implement the ModuleObserver protocol to get notified when some
// particular module is initialized (e.g. Chartboost Mediation).
func onModuleInitializationCompleted(_ result: ModuleInitializationResult) {
    if result.module.moduleID == ChartboostMediation.coreModuleID {
        if let error = result.error {
            // Handle error
        } else {
            // Success
        }
    }
}