Rewarded 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 HyBidRewardedAd

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

Requesting and displaying the ad

  1. Use the load method to request an Ad.
self.rewardedAd.load()
[self.rewardedAd load];
extension ViewController : HyBidRewardedAdDelegate
{
    func rewardedDidLoad()
    {
        print("Rewarded Ad did load:")
        self.rewardedAd.show()

     // or alternatively you can show the rewarded ad from the specified view controller
       self.rewardedAd.show(from: viewController)
    }

    func rewardedDidFailWithError(_ error: Error!)
    {
        print("Rewarded Ad did fail with error: \(error.localizedDescription)")
    }
    
    func rewardedDidTrackClick()
    {
        print("Rewarded Ad did track click:")
    }
    
    func rewardedDidTrackImpression()
    {
        print("Rewarded Ad did track impression:")
    }
    
    func rewardedDidDismiss()
    {
        print("Rewarded Ad did dismiss:")
    }

    func onReward()
    {
        print("Rewarded.")
    }
}
#pragma mark - HyBidRewardedAdDelegate

- (void)rewardedDidLoad
{
    NSLog(@"Rewarded Ad did load");
    [self.rewardedAd show];

// or alternatively you can show the rewarded ad from the specified view controller
    [self.rewardedAd showFromViewController:viewController];
}

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

- (void)rewardedDidTrackClick
{
    NSLog(@"Rewarded Ad did track click");
}

- (void)rewardedDidTrackImpression
{
    NSLog(@"Rewarded Ad did track impression");
}

- (void)rewardedDidDismiss
{
    NSLog(@"Rewarded Ad did dismiss");
}

- (void)onReward
{
    NSLog(@"Rewarded.");
}

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 HyBidRewardedAd will render it and notify when it's ready via the rewardedDidLoad callback. Any error during fetch or rendering will be received via the rewardedDidFailWithError callback.

rewardedDidTrackClick, rewardedDidTrackImpression rewardedDidDismiss and just notify of clicks, impressions and dismissal of the Rewarded Ad. 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.

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 HyBidRewardedAd can be used. It is enabled by default.

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

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

func rewardedDidLoad() {
    self.rewardedAd.prepare()
}
- (void)rewardedDidLoad {
    [self.rewardedAd 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