iOS SDK MoPub Adapter

135 views 10/05/2018 Shay Karpeles 0

Getting Started

This document details the process of integrating YouAppi’s SDK MoPub adapter with your iOS app.

If you have any question you can email us to: sdk@youappi.com

 

Automatic: Setup your project with CocoaPods

You can setup your project with YouAppi’s SDK automatically using CocoaPods.

Steps for using CocoaPods:

  • Make sure CocoaPods is installed on your Mac.
  • Make sure your project has a pod file.
  • Add to your pod file YouAppi’s framework and YouAppi’s MoPub adapter:

    target 'MyApp' do
      pod 'YouAppiMoatSDK'
      pod 'YouAppiMoPubAdapter'
      pod 'mopub-ios-sdk'
    end
  • Please note that: mopub-ios-sdk might have already been added to your pod file if you are working with MoPub mediation.
  • Open a terminal and change the current directory to your project directory.
  • Run the command:

    pod install
  • After YouAppi framework is setup for your project, you can move on to the integration section of the document.

Manual: Setup your project for YouAppi’s SDK

  • YouAppi SDK and YouAppi AdMob adapter can be found in YouAppi iOS SDK zip file.
  • Install YouAppi iOS SDK as described in the document.
  • Add libMopubYouAppiAdapter.a static library to your project.
  • After YouAppi framework is setup for your project, you can move on to the integration section of the document.

Create YouAppi custom network

  • On MoPub platform on Networks tab, add a new custom network for YouAppi:
  • On the popup that opens choose to add a Custom Native Network.

  • Name your new network (YouAppi might be a good name) and fill other relevant details.

Setup MoPub for YouAppi Ad units

Create rewarded video ad anit

  • On your MoPub account, press Apps tab.
  • Select your iOS app for which you would like or create the new ad unit or create a new iOS app.
  • On your app screen press “New ad unit” button:
  • Name your add unit, select Format: Rewarded Video and press Save

Create Interstitial Video or Interstitial Ad units

  • Assuming you already created an iOS app, press Apps tab and from the apps list choose your iOS app.
  • Press New ad unit button to define a new ad unit for either Interstitial Video or Interstitial Ad.
  • Name you ad unit, choose relevant device and on format choose Fullscreen:

Setup Ad Unit on network

  • Choose Networks and select your YouAppi custom network.
  • On network details screen choose Edit Network.
  • On Set Up Your Inventory section, connect between your iOS app ad unit and YouAppi by setting the proper Custom Event Class.
  • For each ad unit type there is a different custom event class:
    • Rewarded Video: YAMoPubRewardedVideoAdEvent
    • Interstitial Video: YAMoPubInterstitialVideoAdEvent
    • Interstitial Ad: YAMoPubInterstitialAdEvent

Enable YouAppi ad unit to run on YouAppi custom network

  • Press Segments tab and choose your desired segment.
  • Under your iOS app find your desired ad unit and YouAppi custom network.
  • Switch your network to running by pressing the button under Enabled column:

Use MoPub SDK to show YouAppi ad units

Rewarded Video

Load

// Initialize rewarded video before loading any ads
[[MoPub sharedInstance] initializeRewardedVideoWithGlobalMediationSettings:nil delegate:self];
     
// Load rewarded video ad
[MPRewardedVideo loadRewardedVideoAdWithAdUnitID:"MoPubRewardedUnitID" withMediationSettings:nil];

Show

if ([MPRewardedVideo hasAdAvailableForAdUnitID:"MoPubRewardedUnitID"]){
  [MPRewardedVideo presentRewardedVideoAdForAdUnitID:"MoPubRewardedUnitID" fromViewController:self];
}

Interstitial Video

Load

interstitialVideo = [MPInterstitialAdController interstitialAdControllerForAdUnitId: "MoPubInterstitialVideoUnitID"];
interstitialVideo.delegate = self;
[interstitialVideo loadAd];

Show

if (interstitialVideo.ready){
  [interstitialVideo showFromViewController:self];
}

Interstitial Ad

Load

interstitialAd = [MPInterstitialAdController interstitialAdControllerForAdUnitId:"MoPub InterstitialADUnitID"];
interstitialAd.delegate = self;
[interstitialAd loadAd];

Show

if (interstitialAd.ready){
  [interstitialAd showFromViewController:self];
}

Demo App

A demo app showing a simple usage of the SDK can be found in the following bitbucket repository:

https://bitbucket.org/youappi/youappi-sdk-ios-demo-simple

The demo app contains 3 modules:

  • AppDemo – Shows how to use YouAppi’s SDK
  • AppDemoAdMob – Shows how to use YouAppi’s SDK with AdMob adapter
  • AppDemoMoPub – Shows how to use YouAppi’s SDK with MoPub adapter

Please make sure to read the README.md file for further instructions.