Banner

Banner ads are added as a subview inside your application. Consumers of your application can tap the banner ad to interact with it.

As of v5.7.1 will handle the refresh interval itself. Please make sure that the refresh interval in the ad network dashboard is disabled, otherwise you may experience unexpected behaviour

1. Load the banner

To begin preparations for displaying a banner ad, navigate to the header file that you want the banner ad to appear in (e.g. MyViewController.h/ViewController.swift) and add the following:

Objective-C
Swift
#import <Tapdaq/Tapdaq.h>

@interface MyViewController : UIViewController <TapdaqDelegate, TDBannerAdRequestDelegate>

@property (nonatomic, strong) UIView *bannerView;

The above code imports Tapdaq to the class, and declares that we will conform to the TapdaqDelegate protocol. We have also added a UIView property to the class, which we will load the banner into.

Please note that you only need to provide import statement once per header file.

Next, add the following command to the implementation file (e.g. MyViewController.m/ViewController.swift) inside a method of your choice to load the banner:

Objective-C
Swift
- (void)myMethod {
    [[Tapdaq sharedSession] loadBannerForPlacementTag:@"my_banner_tag" withSize:TDMBannerSizeStandard delegate:self];
}

Delegate parameter must conform to TDBannerAdRequestDelegate.

The banner needs to be loaded for a specific size. You can see a full list of TDMBannerSizes here

Alternatively a custom size banner can be loaded. Tapdaq SDK will automatically select the most suitable banner size for the target size specified in the following method:

Objective-C
Swift
- (void)myMethod {
    [[Tapdaq sharedSession] loadBannerForPlacementTag:@"my_banner_tag" targetSize:CGSizeMake(340, 60) delegate:self];
}

Note: Ads should only be requested once the Tapdaq delegate method -didLoadConfig has been called. This ensures Tapdaq is initialised and ready to begin loading ads. Requesting ads prior to Tapdaq initialising will result in failed ad requests

2. Display the banner

Once this is done, implement the following in the class conforming to TDBannerAdRequestDelegate which was passed when the banner was loaded:

Objective-C
Swift
- (void)didLoadBannerAdRequest:(TDBannerAdRequest *)adRequest {
    if ([adRequest.placement.tag isEqualToString:@"my_banner_tag"]) {
        self.bannerView = [adRequest bannerView];
        // Place it at the bottom
        [self.bannerView setFrame:CGRectMake(
            (self.view.frame.size.width-self.bannerView.frame.size.width)/2,
            self.view.frame.size.height-self.bannerView.frame.size.height,
            self.bannerView.frame.size.width,
            self.bannerView.frame.size.height
        )];

        // Add it to your view
        [self.view addSubview:self.bannerView];
    }
}

3. Hide the banner

To hide the banner, simply remove the UIView from the superview, like so:

Objective-C
Swift
[self.bannerView removeFromSuperview];

Build and run your application to test the advert is displayed correctly.

4. Banner sizes

TDMBanner sizes

Banner Size AdColony AppLovin Facebook Audience Network Google Ad Mob InMobi Mintegral UnityAds
TDMBannerStandard 320x50 320x50 320x50 320x50 320x50 320x50 320x50
TDMBannerLarge N/A N/A 320x90 320x100 N/A 320x90 N/A
TDMBannerMedium 300x250 300x250 300x250 300x250 300x250 300x250 N/A
TDMBannerFull N/A N/A N/A 468x60 N/A N/A 468x60
TDMBannerLeaderboard 728x90 N/A N/A 728x90 N/A 728x90 728x90
TDMBannerSmart N/A N/A Various x (from 50 up to 15% of screen height) Various x 50 N/A N/A N/A
TDMBannerCustom Various x Various Various x Various Various x Various Various x Various Various x Various Various x Various Various x Various

5. Delegates

Implementing the TDBannerAdRequestDelegate protocol allows listening to loading events from ads.

Loaded an ad

Called immediately after an ad has been successfully loaded.

Objective-C
Swift
- (void)didLoadBannerAdRequest:(TDBannerAdRequest * _Nonnull)adRequest;

Failed to load an ad

Called when the ad was not able to be loaded.

Objective-C
Swift
- (void)adRequest:(TDAdRequest * _Nonnull)adRequest didFailToLoadWithError:(TDError * _Nullable)error;

Implementing the TDBannerAdRequestDelegate protocol allows you to listen to banner refresh requests.

Refresh a banner ad

Called when the ad within the banner view loads another ad.

Objective-C
Swift
- (void)didRefreshBannerForAdRequest:(TDBannerAdRequest * _Nonnull)adRequest;

In case banner fails to refresh the following delegate method is called.

Objective-C
Swift
- (void)didFailToRefreshBannerForAdRequest:(TDBannerAdRequest * _Nonnull)adRequest withError:(TDError * _Nullable)error;

Need help?

If you are having any problems integrating, feel free to contact us on [email protected] and we will be more than happy to help.

What's next?

Now that you have successfully integrated a banner into your app, what would you like to do next?