Integrate with MoPub

If you already have MoPub ads serving in your app, but want to integrate AwesomeAds as well, without having to directly use the iOS Publisher SDK, you can follow the steps below:

Add the MoPub plugin

Change your Podfile to contain the following:

target 'MyProject' do
    # add the SuperAwesome SDK
    pod 'SuperAwesome', '~> 7.2'

    # add the MoPub plugin
    pod 'SuperAwesome/MoPub', '~> 7.2'
end

and execute

pod update

Setup Custom Networks

Login to the MoPub dashboard using your preferred account.

From here forward the tutorial assumes you have an iOS app with three ad units setup in MoPub; one banner, one interstitial ad and one rewarded video ad:

image-title-here

From your MoPub admin interface you should create a New Order

image-title-here

From the next menu, select New line item

image-title-here

Notice that the custom event class names required by MoPub are:

  • for Banner Ads:

SuperAwesome.AwesomeAdsMoPubBannerAdapter

  • for Interstitial Ads:

SuperAwesome.AwesomeAdsMoPubInterstitialAdapter

  • for Rewarded Video Ads:

SuperAwesome.AwesomeAdsMoPubVideoAdapter

And, you can tell MoPub what AwesomeAds ads to load and how to display them by filling out the custom event class data field with a JSON similar to this:

{
    "placementId": 30473,
    "isTestEnabled": true or false,
    "isParentalGateEnabled": true or false,
    "orientation": "ANY" or "PORTRAIT" or "LANDSCAPE",
    "shouldShowCloseButton": false or false,
    "shouldAutomaticallyCloseAtEnd": true or false,
    "shouldShowSmallClickButton": true or false
}
  • In the second tab Ad unit targeting, Select your App&ad unit e.g. Banner

  • In the third tab Audience targetting, Select your target audience

*Create multiple line items for banner, interstitial, and video(rewarded) ads.

Implement Ads

Initialise the MoPub sdk with AwesomeAds adapter configuration

let configuration = MPMoPubConfiguration.init(adUnitIdForAppInitialization: bannerAdId)
        configuration.loggingLevel = .debug
        configuration.additionalNetworks = [AwesomeAdsMoPubAdapterConfiguration.self]
                
        MoPub.sharedInstance().initializeSdk(with: configuration) {
            print("MoPub SDK initialisation complete")
            
            self.configureBanner()
            self.configureInterstitial()
            self.configureVideo()
        }

Once the previous steps are done, you can add MoPub banners, interstitials and rewarded video ads just as you normally would:

Since the previously created custom events will run on these ads, and the iOS Publisher SDK is integrated alongside the MoPub plugin, you should start seeing ads playing.