iosswiftmopub

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


Solution

  • 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)