Interstitial Ads will be rendered using the HyBid SDK.

Requirements

  • Ad Zone ID from the PubNative Publisher Dashboard.

Demo App

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

Create and initialize a HyBidInterstitialAd

  1. Import HyBid into your class.
import HyBid
#import <HyBid/HyBid.h>
  1. Create a HyBidInterstitialAd property and initialize it by passing your Ad Zone ID and also your registered view controller as the interstitialAd's delegate (HyBidInterstitialAdDelegate).
var interstitialAd : HyBidInterstitialAd!
self.interstitialAd = HyBidInterstitialAd(zoneID: <YOUR AD ZONE ID HERE>, andWith: self)
@property (nonatomic, strong) HyBidInterstitialAd *interstitialAd;
self.interstitialAd = [[HyBidInterstitialAd alloc] initWithZoneID:<YOUR AD ZONE ID HERE> andWithDelegate:self];

Requesting and displaying the ad

  1. Use the load method to request an Ad.
self.interstitialAd.load()
[self.interstitialAd load];
extension ViewController : HyBidInterstitialAdDelegate
{
    func interstitialDidLoad()
    {
        print("Interstitial did load:")
        self.interstitialAd.show()
      
        // or alternatively you can show the interstitial ad from the specified view controller
       self.interstitialAd.show(from: viewController)
    }

    func interstitialDidFailWithError(_ error: Error!)
    {
        print("Interstitial did fail with error: \(error.localizedDescription)")
    }
    
    func interstitialDidTrackClick()
    {
        print("Interstitial did track click:")
    }
    
    func interstitialDidTrackImpression()
    {
        print("Interstitial did track impression:")
    }
    
    func interstitialDidDismiss()
    {
        print("Interstitial did dismiss:")
    }
}
#pragma mark - HyBidInterstitialAdDelegate

- (void)interstitialDidLoad
{
    NSLog(@"Interstitial did load");
    [self.interstitialAd show];
    
    // or alternatively you can show the interstitial ad from the specified view controller
    [self.interstitialAd showFromViewController:viewController];
}

- (void)interstitialDidFailWithError:(NSError *)error
{
    NSLog(@"Interstitial did fail with error: %@",error.localizedDescription);
}

- (void)interstitialDidTrackClick
{
    NSLog(@"Interstitial did track click");
}

- (void)interstitialDidTrackImpression
{
    NSLog(@"Interstitial did track impression");
}

- (void)interstitialDidDismiss
{
    NSLog(@"Interstitial did dismiss");
}

If you don't want to show the ad right away after being loaded, you can use the isReady property that returns a BOOL stating if the ad has been loaded and is ready to be displayed.

Once the ad is loaded successfully from the server, the HyBidInterstitialAd will render it and notify when it's ready via the interstitialDidLoad callback. Any error during fetch or rendering will be received via the interstitialDidFailWithError callback.

interstitialDidTrackClick, interstitialDidTrackImpression interstitialDidDismiss and just notify of clicks, impressions and dismissal of the Interstitial. No code needs to be added there. Use those callbacks in case you want to hide the ad after click or some similar use case.

Skip Offset

The Interstitial can display two kinds of ads: HTML and Video. On HyBidInterstitialAd you can set manually a minimum amount of seconds until the ad can be skipped.

self.interstitialAd.setHTMLSkipOffset(2) //2 seconds
self.interstitialAd.setVideoSkipOffset(5) //5 seconds
[self.interstitialAd setHTMLSkipOffset:2]; //2 seconds
[self.interstitialAd setVideoSkipOffset:5]; //5 seconds

Disable Asset Caching

In some integration scenarios like in-app bidding, pre-caching the ad assets is not needed since there’s no guarantee that the ad will end up being displayed. For this reason the HyBid SDK provides controls to disable ad caching. This will allow you to access properties like the bid price right after the ad server has responded with a creative.

To disable the ad caching, the function:

func isAutoCacheOnLoad(_ isAutoCacheOnLoad: Bool)
- (void)setIsAutoCacheOnLoad:(BOOL)isAutoCacheOnLoad;

in the HyBidInterstitialAd can be used. It is enabled by default.

var interstitialAd = HyBidInterstitialAd(zoneID: "<YOUR AD ZONE ID HERE>", andWith: self)
self.interstitialAd?.isAutoCacheOnLoad = false
HyBidInterstitialAd *interstitialAd = [[HyBidInterstitialAd alloc] initWithZoneID:@”<YOUR AD ZONE ID HERE>” andWithDelegate:self];
[interstitialAd setIsAutoCacheOnLoad: NO];

Once the ad has finished loading, the prepare function can be used to force a creative cache. This will ensure that the interstitial renders faster, thus creating a smoother user experience.

func interstitialDidLoad() {
    interstitialAd?.prepare()
}
- (void)interstitialDidLoad {
    [self.interstitialAd prepare];
}

You can use the show function as usual to render the ad. Even if prepare is not called, the rendering will work as well but the user might notice a small delay for video ads.

Return to the HyBid