iosadmobmopubmobile-ad-mediation

How do I setup MoPub mediation with Admob (google) for iOS?


I have MoPub banner ads working (via MoPub Marketplace) in my iOS app. I'm able to show production or test MoPub ads.

I don't understand how to use mediation to serve MoPub + Admob ads. I'm following the MoPub integration guide here https://developers.mopub.com/publishers/mediation/networks/google/

I'm using Cocoapods, so I have these 3 pods in my app:

    pod 'mopub-ios-sdk'
    pod 'MoPub-AdMob-Adapters', '7.64.0.1'
    pod 'Google-Mobile-Ads-SDK'

I'm able to run my app and see MoPub test ads.

I'm reading MoPub's test guide, but it's not clear to me how this works. https://developers.mopub.com/publishers/ios/test/

Questions, sorry for my basic understanding of the setup:

  1. What does the admob integration actually require? I've added the AdMob Adapter & AdMob SDK. I've also updated my Info.plist with my test AdMob ID. It's not clear to me if I have to implement the admob UIView in my ViewController or if that is something the adapter and MoPub mediation handles? What setup do I need besides adding the Pods & adding the app ID to my Info.plist in my app?
  2. How do I setup AdMob in MoPub? I'm trying to follow their guide, but it's confusing. I went in MoPub Networks tab and linked Admob using Oauth. Reporting access is enabled. Do I put my Admob add unit ID in "App & ad unit setup" tab? Admob now has two IDs: one for Info.plist, one for actual served ad unit. I also created an Order for Admob as a Network line item.
  3. How do I setup the waterfall? My guess is the Mopub Orders tab. This is confusing since I have a preexisting "MoPub Demo Order" that I think I want to disable? Do I need to add Mopub as a Marketplace line item to my orders?

Overall, I'm pretty confused since this is all new to me. I tried disabling my MoPub ads to test showing my test Admob ads, but it's not working. I'm using test IDs in both the Info.plist & Admob add unit ID (in Mopub). How do I make sure Admob is setup correctly and show test ads in development?


Solution

  • First, your Podfile has both pod 'MoPub-AdMob-Adapters' and pod 'Google-Mobile-Ads-SDK', which isn't necessary because the former has the latter declared as a transitive dependency. So, you only need to add pod 'MoPub-AdMob-Adapters' to your Podfile, and both the adapters and Google's Mobile Ads SDK will be fetched.

    In the future, it's best to use the Mediation Integration Tool available at https://developers.mopub.com/publishers/mediation/integrate/ to integrate adapters. Just find the ad networks you are interested in, and hit the toggle button to get the Gradle/CocoaPods configuration to add to your app.

    Now, to your questions:

    1. When you use mediation with MoPub, you do not manually add the mediation SDKs or use their APIs. This is because MoPub handles calling the mediation APIs via the adapters, so all your need to do is integrate the adapters (what I said above), and continue using MoPub's APIs to request and serve ads (just as you would for Marketplace ads). As an example, here is the MoPub AdMob adapter for banner. You can see it handles allocating the AdMob UIView, requesting ad, and returning the ad to MoPub's SDK.

    2. Yes, you use the AdMob ad unit IDs (not the application ID that goes into your info.plist) in the "App and ad unit setup" tab. The same applies to other ad networks - you will use their ad unit IDs (also called placements, depending on the network) rather than their application IDs, which typically go into your app.

    3. There is no right or wrong way to set up your waterfall. It all depends on your preference. If you just want to test that your setup with AdMob is working, I suggest creating a simple waterfall like below:

      1. Create a brand new MoPub ad unit ID for banner.
      2. Disable the MoPub Marketplace line item (for testing purposes). You should turn it back on later when deploying your app with MoPub.
      3. Go to the "Networks" tab, and paste your AdMob ad unit ID into the equivalent MoPub ad unit box. Save.
      4. Go to the "Segments" tab > "Global Segment", and enter a high eCPM value for your AdMob ad unit.
      5. Go back to your MoPub ad unit ID in the "Apps" tab. It should now enabled with AdMob.
      6. Plug the MoPub ad unit ID into your app and make an ad request. Check the console/device logs, there should be log messages telling you this ad is served by AdMob.

    For more information on what different things mean when setting up your waterfall, check out the developer docs at https://developers.mopub.com/publishers/ui/manage-marketplace/.