Banner Ads

Banner ads provide a great way to add an additional revenue stream with minimal impact to the flow and usage of your app.

The MobileFuse SDK also supports delivery of expandable rich-media banner ads by default, which are more interactive and engaging than standard banner placements.


Display a banner ad in your app

The MFBannerAd class allows you to create and render banner ads within your app.



Valid banner ad sizes are:


Your banner ad instance will render itself as a child of the view that you pass in to the loadAd method.

To create the banner ad, first allocate and initialize it with the size and placement ID that you’d like to use. Then register the callback receiver, add it as a subview, and finally call loadAd, the following sample code demonstrates this process:

MFBannerAd *bannerAd;

- (void)loadBanner {
    // UI on main thread
    dispatch_async(dispatch_get_main_queue(), ^ {
        bannerAd = [[MFBannerAd alloc] initWithPlacementId:@"000000" withSize:MOBILEFUSE_BANNER_SIZE_320x50];
        [bannerAd registerAdCallbackReceiver:self];
        [self.view addSubview:bannerAd];

        [bannerAd loadAd];



Ensure that you adjust the user interface of your app to account for the positioning of the banner. You should leave a margin between the displayed banner ad and your app UI to avoid potential mis-clicks on the ad creative.

Listening for event callbacks

Optionally, you can implement IMFAdCallbackReceiver to receive events from the banner ad instance. Pass the implementation to the registerAdCallbackReceiver method to start receiving callbacks

[bannerAd registerAdCallbackReceiver: self];

-(void) onAdLoaded: (MFAd *) ad {
    // The ad has loaded - you are able to show the ad once this callback has triggered
-(void) onAdNotFilled: (MFAd *) ad {
    // There is no ad currently available to show to this user
-(void) onAdClosed: (MFAd *) ad {
    // The ad has been displayed and then closed
-(void) onAdRendered: (MFAd *) ad {
    // Triggered when the ad is first shown to the user
-(void) onAdExpanded: (MFAd *) ad {
    // The ad has been expanded into full screen - will only be triggered for expandable banner ads
-(void) onAdCollapsed: (MFAd *) ad {
    // The ad has been collapsed back down into standard banner size
-(void) onAdClicked: (MFAd *) ad {
    // The user has clicked the ad
-(void) onAdExpired: (MFAd *) ad {
    // The ad has expired before being displayed - you should manually try to load a new ad here
-(void) onAdError: (MFAd *)ad withMessage: (NSString *)message {
    // An error occured - the message argument will contain details of what went wrong

Display the ad

Once the banner ad has triggered the onAdLoaded callback, you can then call showAd() to instantly display the ad:

[bannerAd showAd];

You can also use isLoaded to check whether the ad is ready to be displayed.

if ([bannerAd isLoaded]) {
    // The ad is ready to be displayed!
    [bannerAd showAd];



Once you call showAd() on an instance, the loaded ad will be displayed. Since a loaded ad can only be displayed once, you must call loadAd() again once the ad is closed to get a new ad ready to display.

Destroying an ad

Call the destroy method to remove and deallocate the banner ad’s resources:

[bannerAd destroy];

Advanced: Configure Ad Rotation

Banner ads can be set to rotate on a pre-set time interval. This is useful to increase the number of banner impressions that will be shown to your users. By default banner ad rotation is disabled. The minimum refresh period is 30 seconds - you cannot set the banner to auto refresh more frequently than once every 30 seconds.

Example: Configure ad to refresh every 60 seconds

[bannerAd setAutorefreshEnabled:YES];
[bannerAd setAutorefreshInterval:60];

Example: Manually handle refreshing of the ad

For example you may want to fetch a new ad when a view is changed within your app

// On view change:
[bannerAd forceRefresh];