Skip to content

HyBid Interstitial Ads

Can Soykarafakılı edited this page Oct 8, 2018 · 23 revisions

Interstitial Ads will be rendered using the HyBid SDK.

Requirements

  • Ad Zone ID from the PubNative Publisher Dashboard

Create and initialize a HyBidInterstitialAd

  1. Import HyBid into your class.

Swift:

import HyBid

Objective-C:

#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).

Swift:

var interstitialAd : HyBidInterstitialAd!
self.interstitialAd = HyBidInterstitialAd(zoneID: <YOUR AD ZONE ID HERE>, andWith: self)

Objective-C:

@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.

Swift:

self.interstitialAd.load()

Objective-C:

[self.interstitialAd load];

Swift:

extension ViewController : HyBidInterstitialAdDelegate
{
    func interstitialDidLoad()
    {
        print("Interstitial did load:")
        self.interstitialAd.show()
    }

    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:")
    }
}

Objective-C:

#pragma mark - HyBidInterstitialAdDelegate

- (void)interstitialDidLoad
{
    NSLog(@"Interstitial did load");
    [self.interstitialAd show];
}

- (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.

Home

Installations & Configurations

Displaying Ads with HyBid

Displaying Ads with Header Bidding with GAM

Mediation

Advanced Setup

Integration Checklists for Publishers

Misc

Clone this wiki locally