Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save skparticles/1c8cc450b37e6ce89fe465ebfef7afbb to your computer and use it in GitHub Desktop.
Save skparticles/1c8cc450b37e6ce89fe465ebfef7afbb to your computer and use it in GitHub Desktop.
#import "AdIntegrator.h"
#import <HeyzapAds/HeyzapAds.h>
/**
1. Include Interface to hold banner reference
*/
@interface AdIntegrator()
@property(nonatomic,weak)HZBannerAd *banner;
@end
@implementation AdIntegrator
+ (id)shared{
static AdIntegrator* integrator = nil;
@synchronized(self){
if(integrator == nil){
integrator = [[self alloc] init];
}
}
return integrator;
}
#pragma mark Core Methods
- (void)initAds{
NSLog(@"[Ads] initialization");
//2. Enter Publisher Id
[HeyzapAds startWithPublisherID: @"XXXXXXXX"];
}
-(void)showBanner{
NSLog(@"[Ads] show banner");
//3. Show Banner
if(!self.banner){
HZBannerAdOptions *options = [[HZBannerAdOptions alloc] init];
[HZBannerAd placeBannerInView:[UIApplication sharedApplication].keyWindow.rootViewController.view
position:HZBannerPositionBottom
options:options
success:^(HZBannerAd *banner) {
self.banner = banner;
}
failure:^(NSError *error) {
NSLog(@"Error = %@",error);
}
];
}else{
[self.banner setHidden: NO];
}
}
-(void)showInterstitial{
NSLog(@"[Ads] show interstitial");
//4. Add Interstital Ads Code
// Interstitial Ads are automatically fetched from our server by default on SDK start and after an ad shows
HZShowOptions *options = [[HZShowOptions alloc] init];
options.viewController = [UIApplication sharedApplication].keyWindow.rootViewController;
[HZVideoAd showWithOptions:options];
}
-(void)hideBanner{
NSLog(@"[Ads] hide banner");
// Hide the banner ad
if(self.banner)
[self.banner setHidden: YES];
}
-(bool)isBannerVisible{
return true;
}
-(bool)isRewardedVideoAvialable{
return true;
}
-(void)showRewardedVideo{
NSLog(@"[Ads] show rewarded video");
}
#pragma mark Integration
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment