hoseong
hoseong

Reputation: 3

how to set ...initialize multiple unit id in mopub ios sdk

my code

let config = MPMoPubConfiguration.init(adUnitIdForAppInitialization:"ad_unit_id")
        config.loggingLevel = .none

        MoPub.sharedInstance().initializeSdk(with: config) {
            print("mopub now use!!")
        }

why onle one unitid input? my app is use both banner and reward.. What should I enter? plz..help

Upvotes: 0

Views: 109

Answers (2)

Seun Oboite
Seun Oboite

Reputation: 68

As per Mopub guidelines, you only need to initialise one ad unit ID belonging to the app.

Initialize once per app’s lifecycle, typically on app launch, using any valid ad unit ID that belongs to the specific app you’re initializing with MoPub.

You can do this by:

let sdkConfig = MPMoPubConfiguration(adUnitIdForAppInitialization: "YOUR_AD_UNIT")
sdkConfig.loggingLevel = .none
sdkConfig.allowLegitimateInterest = true

// Mopub Configuration
MoPub.sharedInstance().grantConsent()
MoPub.sharedInstance().allowLegitimateInterest = false
MoPub.sharedInstance().initializeSdk(with: sdkConfig, completion: nil)

Extract from Motics Mopub Blog.

Upvotes: 0

Yogendrasinh Jadeja
Yogendrasinh Jadeja

Reputation: 36

If you want to initialise multiple ads units in mopub you can do like this:

    let sdkConfigBanner = MPMoPubConfiguration(adUnitIdForAppInitialization:MOPUB_AD_BANNER)
    sdkConfigBanner.loggingLevel = .info
    MoPub.sharedInstance().initializeSdk(with: sdkConfigBanner, completion: nil)


    let sdkConfigReward = MPMoPubConfiguration(adUnitIdForAppInitialization:MOPUB_AD_REWARD)
    sdkConfigReward.loggingLevel = .info
    MoPub.sharedInstance().initializeSdk(with: sdkConfigReward, completion: nil)

Upvotes: 2

Related Questions