MoPub SDK Initialization

The MoPub 5.0 SDK introduces a new API for initialization called MoPub.InitializeSdk(). This API is necessary for a number of new functionalities, including GDPR consent mechanisms and rewarded video. If you have been using MoPub.RewardedVideoInit, it is now part of the new initialization, so make sure to switch to the new API.

Instructions

You only need to initialize once using any valid ad unit ID from your app. Ad requests should only be made once the SDK initialization has completed.

  1. In your app’s Start(), instantiate an SdkConfiguration object with any valid ad unit ID from your app, your mediation settings (optional), and/or a list of mediated rewarded video adapters (optional).
  2. Call MoPub.InitializeSdk() and pass in the SdkConfiguration object.

Example

private void Start()
{
    // Create and instantiate an SdkConfiguration
    var sdkConfig = new MoPub.SdkConfiguration {
        AdUnitId = // Any ad unit ID your app uses

        /* (Optional) Mediation settings
        These dictionaries are serialized to JSON and passed to the native SDKs for handling, so the object values must be JSON-serializable. */
        MediationSettings = {
            new MediationSetting("ad vendor") {
                { "key1", value1 },
                { "key2", value2 },
            },
        },

        // (Optional) A list of rewarded video adapters to initialize
        NetworksToInit = {
            MoPub.RewardedNetwork.AdColony,
            MoPub.RewardedNetwork.Facebook
        }
    };
    MoPub.InitializeSdk(sdkConfig);
    // Publishers can override MoPubEventListener.OnSdkInitializedEvent() to get a callback.
    // Alternatively, publishers can call "yield return WaitUntil(() => MoPub.IsSdkInitialized)" to suspend the coroutine execution until the SDK has initialized.
}

Last updated September 16, 2018

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2018 MoPub Inc.