iOS Ad Formats

Banner Interstitial Rewarded Medium Rectangle

Banner Ads

After creating placements in the DT Console, add the following code snippets in the chosen context of your app. Access the Placement ID by using the copy button next to the placement name. For more information about creating placements in the DT Console, read here.

Screen

Banners are rectangle ads appearing either at the top or bottom of the screen when the user interacts with your app. The user can view them but cannot dismiss them. Banners are automatically refreshed by the DT FairBid SDK after 20 seconds.

The DT FairBid SDK refreshes banners automatically. To avoid discrepancies between Digital Turbine and 3rd-party network reporting, disable any automatic or manual banner refresh settings on 3rd-party network SDKs.

Showing a Banner

To show a banner, implement the code below:

Objective-C
// in implementation of FYBBannerDelegate protocol 
  
  - (void)bannerDidLoad:(FYBBannerAdView *)banner impressionData:(FYBImpressionData *)impressionData {
      [self.myView addSubview:banner];
      banner.center = CGPointMake(self.myView.bounds.size.width / 2, self.bounds.size.height / 2);
  }
  
Swift
extension MyViewController: FYBBannerDelegate {
  
      func bannerDidLoad(_ banner: FYBBannerAdView, impressionData: FYBImpressionData)
      {
        // set up the banner constraints
         myView.addSubview(banner)
         banner.center = CGPoint(x: myView.frame.width / 2, y: myView.center.y)
      }
  
      …
  }
  

Hiding the Banner

If you want to hide the banner temporarily, implement the code below:

Objective-C
NSString *placementId = @"1234"; [FYBBanner hide:placementId];
Swift
let placementId = "1234" FYBBanner.hide(placementId)

Destroying the Banner

Once you have decided that you no longer want to use the banner, you must destroy it.

To destroy the banner, implement the code below:

Objective-C
NSString *placementId = @"1234"; [FYBBanner destroy:placementId];
Swift
let placementId = "1234" FYBBanner.destroy(placementId)

Loading a Banner

Important

This is only recommended if FairBid is not your main mediation platform.

You can pre-load a banner to review its pricing and other details if you want to use FairBid with other mediations or demand sources. This allows you to compare it against banners from other demand sources outside our platform before showing it.

You are responsible for adding FYBBannerAdView instance to your view hierarchy. This FYBBannerAdView instance is available on - bannerDidLoad:impressionData: callback

To pre-load a banner, implement the code below:

Objective-C

    #import <FairBidSDK/FairBid.h>
    /// 1. Assign FYBBannerDelegate instance to handle banner events
    FYBBanner.delegate = self;

    /// 2. Define the banner placement ID
    /// Replace banner placementId with your actual banner placement id
            
    NSString *placementId = <#banner placementId#>;

    /// 3. Initialize a new FYBBannerOptions instance with a specified placement ID and size. 
    /// FYBBannerSizeSmart automatically adjusts the banner size based on the device's screen width.
            
    FYBBannerOptions *bannerOptions = [[FYBBannerOptions alloc] initWithPlacementId:placementId size:FYBBannerSizeSmart];
    
    /// 4. Request to load a banner ad with the specified options. This method fetches the banner creative but does not show it.
    [FYBBanner requestWithOptions:bannerOptions];
Swift
 
      /// 1. Assign FYBBannerDelegate instance to handle banner events
      FYBBanner.delegate = self

      /// 2. Define the banner placement ID
      /// Replace banner placementId with your actual banner placement id
      let placementId = <#banner placementId#>

      /// 3. Initialize a new FYBBannerOptions instance with a specified placement ID and size. 
      ///FYBBannerSizeSmart automatically adjusts the banner size based on the device's screen width.
      let bannerOptions = FYBBannerOptions(placementId: placementId, size: .smart)
            
      /// 4. Request to load a banner ad with the specified options. This method fetches the banner creative but does not show it.
      FYBBanner.request(with: bannerOptions)

Adaptive Banners

By enabling the adaptive banner feature, you can receive the best banner size based on the ad width and screen size. This feature is currently supported by Google AdMob, Google Bidding, and Google Ad Manager only. This feature is disabled by default.

Networks that support adaptive banners will return ads with the best-fit height based on your banner size. Other networks will continue to deliver banners according to the specified ad size.

To use this feature, add the "adaptive" flag when defining your banner size using the code below:

Objective-C
NSString *placementId = @"12345";
FYBBannerOptions *options = [[FYBBannerOptions alloc] initWithPlacementId:placementId position:FYBBannerAdViewPositionTop];
options.adaptive = YES;
[FYBBanner showBannerInView:view options:options];
Swift
let view: UIView = parent!.navigationController!.tabBarController!.view
let placementId = "12345"
let options = FYBBannerOptions(placementId: placementId, position: .bottom)
options.adaptive = true
FYBBanner.show(in: view, options: options)

 

Adding Callbacks

The callback code below is required for the SDK to properly track the activity of your ad.

Objective-C
#import <FairBidSDK/FairBid.h> 

@interface MyBannerDelegate : NSObject
@end

@implementation MyBannerDelegate
- (void)bannerDidLoad:(FYBBannerAdView *)banner impressionData:(FYBImpressionData *)impressionData {
// Called when an ad is loaded }
- (void)bannerDidFailToLoad:(NSString *)placementId withError:(NSError *)error {
// Called when an error arises when loading an ad }
- (void)bannerDidShow:(FYBBannerAdView *)banner impressionData:(FYBImpressionData *)impressionData { // Called when banner shows up }
- (void)bannerDidClick:(FYBBannerAdView *)banner { // Called when banner is clicked }
- (void)bannerWillPresentModalView:(FYBBannerAdView *)banner { // Called when banner presents modal view
}
- (void)bannerDidDismissModalView:(FYBBannerAdView *)banner { // Called when banner hides presented modal view }
- (void)bannerWillLeaveApplication:(FYBBannerAdView *)banner { // Called after banner redirects to other application }
- (void)banner:(FYBBannerAdView *)banner didResizeToFrame:(CGRect)frame { // Called after banner changes its size to desired frame }
- (void)bannerWillRequest:(NSString *)placementId withRequestId:(NSString *)requestId {
// Called when a banner is going to be requested. }
@end
Swift
class MyBannerDelegate: NSObject, FYBBannerDelegate { 
    func bannerDidLoad(_ banner: FYBBannerAdView, impressionData: FYBImpressionData) {} 
    func bannerDidFail(toLoad placementId: String, 
withError error: Error) {} func bannerDidShow(_ banner: FYBBannerAdView, impressionData: FYBImpressionData) {} func bannerDidClick(_ banner: FYBBannerAdView){} func bannerWillPresentModalView(_ banner: FYBBannerAdView) {} func bannerDidDismissModalView(_ banner: FYBBannerAdView) {} func bannerWillLeaveApplication(_ banner: FYBBannerAdView) {} func banner(_ banner: FYBBannerAdView, didResizeToFrame frame: CGRect) {} func bannerWillRequest(_ placementId: String, withRequestId requestId: String) {}
}

Back to Top ⇧