-
Notifications
You must be signed in to change notification settings - Fork 4
HyBid Banner Ads (Pre v:2.0.0)
Can Soykarafakılı edited this page Nov 20, 2020
·
1 revision
Banner Ads will be rendered using the HyBid SDK.
-
Ad Zone IDfrom the PubNative Publisher Dashboard
- Import
HyBidinto your class.
Swift:
import HyBidObjective-C:
#import <HyBid/HyBid.h>- Create a
HyBidBannerAdViewproperty and initialize it. (For the sake of simplicity, we use Interface Builder. You can also create theHyBidBannerAdViewproperty programmatically.)
Swift:
@IBOutlet weak var bannerAdView: HyBidBannerAdView!Objective-C:
@property (weak, nonatomic) IBOutlet HyBidBannerAdView *bannerAdView;Use the load method to request an Ad by, passing your Ad Zone ID and also your registered view controller as the bannerAdView's delegate (HyBidAdViewDelegate).
Swift:
self.bannerAdView.load(withZoneID: <YOUR AD ZONE ID HERE>, andWith: self)Objective-C:
[self.bannerAdView loadWithZoneID:<YOUR AD ZONE ID HERE> andWithDelegate:self];Swift:
extension ViewController : HyBidAdViewDelegate
{
func adViewDidLoad(_ adView: HyBidAdView!)
{
print("Banner Ad View did load:")
}
func adView(_ adView: HyBidAdView!, didFailWithError error: Error!)
{
print("Banner Ad View did fail with error: \(error.localizedDescription)")
}
func adViewDidTrackClick(_ adView: HyBidAdView!)
{
print("Banner Ad View did track click:")
}
func adViewDidTrackImpression(_ adView: HyBidAdView!)
{
print("Banner Ad View did track impression:")
}
}Objective-C:
#pragma mark - HyBidAdViewDelegate
- (void)adViewDidLoad:(HyBidAdView *)adView
{
NSLog(@"Banner Ad View did load:");
}
- (void)adView:(HyBidAdView *)adView didFailWithError:(NSError *)error
{
NSLog(@"Banner Ad View did fail with error: %@",error.localizedDescription);
}
- (void)adViewDidTrackClick:(HyBidAdView *)adView
{
NSLog(@"Banner Ad View did track click:");
}
- (void)adViewDidTrackImpression:(HyBidAdView *)adView
{
NSLog(@"Banner Ad View did track impression:");
}Once the ad is loaded successfully from the server, the HyBidBannerAdView will render it and notify when it's ready via the adViewDidLoad callback. Any error during fetch or rendering will be received via the adViewDidFailWithError callback.
adViewDidTrackImpression and adViewDidTrackClick just notify of clicks and impressions. 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.