Interstitial Ads will be rendered using MPInterstitialAdController through the HyBidMoPubHeaderBiddingInterstitialCustomEvent adapter.


  • Ad Zone ID from the PubNative Publisher Dashboard
  • MoPub Ad Unit ID for the Ad Placement that you want to request.

Demo App

You can find a demo app with code samples for this type of integration here.

Create MoPub Interstitial

  1. Declare a MPInterstitialAdController *moPubInterstitial property.
var moPubInterstitial = MPInterstitialAdController()
@property (nonatomic, strong) MPInterstitialAdController *moPubInterstitial;
  1. Instantiate the property that you have declared, passing in your MoPub Ad Unit ID.
self.moPubInterstitial = MPInterstitialAdController (forAdUnitId: "<YOUR MoPUB AD UNIT ID HERE>")
self.moPubInterstitial = [MPInterstitialAdController interstitialAdControllerForAdUnitId:@"<YOUR MoPUB AD UNIT ID HERE>"];
  1. Register your view controller as the moPubInterstitial's delegate (MPInterstitialAdControllerDelegate).
self.moPubInterstitial.delegate = self
self.moPubInterstitial.delegate = self;

For more information about MoPub Interstitial integration, you can refer to the MoPub Documentation as well.

Create HyBid Ad Request

  1. Import HyBid into your class.
import HyBid
#import <HyBid/HyBid.h>
  1. Declare a HyBidInterstitialAdRequest *interstitialAdRequest property.
var interstitialAdRequest =  HyBidInterstitialAdRequest()
@property (nonatomic, strong) HyBidInterstitialAdRequest *interstitialAdRequest;
  1. Instantiate the property that you have declared. After this, you can request an Ad by, passing your Ad Zone ID and also your registered view controller as the interstitialAdRequest's delegate (HyBidAdRequestDelegate).
self.interstitialAdRequest.requestAd(with: self, withZoneID: <YOUR AD ZONE ID HERE>)
self.interstitialAdRequest = [[HyBidInterstitialAdRequest alloc] init];
[self.interstitialAdRequest requestAdWithDelegate:self withZoneID:<YOUR AD ZONE ID HERE>];

Request Ad from MoPub

After the ad is successfully received from PubNative, the request should be made to MoPub with some parameters that will help the ad be chosen properly in the MoPub waterfall.

The HyBidHeaderBiddingUtils must be used so that the SDK can generate the proper keywords for the received ad.

extension ViewController : HyBidAdRequestDelegate
    func requestDidStart(_ request: HyBidAdRequest!)
        print("Request\(request) started")   
    func request(_ request: HyBidAdRequest!, didLoadWith ad: HyBidAd!)
        print("Request loaded with ad: \(ad)")
    if (request == interstitialAdRequest) {
        self.moPubInterstitial.keywords = HyBidHeaderBiddingUtils.createHeaderBiddingKeywordsString(with: ad, with: TWO_DECIMAL_PLACES)
    func request(_ request: HyBidAdRequest!, didFailWithError error: Error!)
        print("Request\(request) failed with error: \(error.localizedDescription)")
#pragma mark - HyBidAdRequestDelegate

- (void)requestDidStart:(HyBidAdRequest *)request
    NSLog(@"Request %@ started:",request);

- (void)request:(HyBidAdRequest *)request didLoadWithAd:(HyBidAd *)ad
    NSLog(@"Request loaded with ad: %@",ad);

     if (request == self.interstitialAdRequest) {
    [self.moPubInterstitial setKeywords:[HyBidHeaderBiddingUtils createHeaderBiddingKeywordsStringWithAdHyBidPrebidUtils createPrebidKeywordsStringWithAd:ad withKeywordMode:TWO_DECIMAL_PLACES]];
    [self.moPubInterstitial loadAd];

- (void)request:(HyBidAdRequest *)request didFailWithError:(NSError *)error
    NSLog(@"Request %@ failed with error: %@",request,error.localizedDescription);
    [self.moPubInterstitial loadAd];

After making this request to MoPub, it will run its waterfall and if the line item targeted by our keywords gets chosen, the HyBidMoPubHeaderBiddingInterstitialCustomEvent adapter will be called to render the ad.

If the ad is ready to be shown, call showFromViewController: on the interstitial, passing in your view controller.

extension ViewController : MPInterstitialAdControllerDelegate
    func interstitialDidLoadAd(_ interstitial: MPInterstitialAdController!)
    { self)
#pragma mark - MPInterstitialAdControllerDelegate

- (void)interstitialDidLoadAd:(MPInterstitialAdController *)interstitial
    [self.moPubInterstitial showFromViewController:self];

Return to the MoPub Header Bidding