Banner ads are images or text that appear on a portion of an app's screen. The ad stays on screen as the user interacts with the app. The ad can auto refresh periodically.
You'll need to follow the instructions in Getting Started before proceeding with the following integration steps. You'll also find a useful example integration in SampleApp included in the SDK download bundle.
Once you've downloaded and installed the PubMatic iOS SDK, use the following sections to implement and configure banner ads:
Display Banner Ad
The steps below walk you through the banner ad implementation process:
Step 1: Import PMBannerAdview header file
Import statements may differ for different integration methods.
Step 2: Setup Banner Ad View
- Create an instance of
- Set the delegate property of the
PMBannerAdViewDelegatein your view controller.
- Add the
PMBannerAdViewas a subview to your view.
Step 3: Create a Banner Ad Request
After you have set up the
PMBannerAdView, create an instance of
adSize property is required and mandatory.
Step 4: Request the Ad
Now you're ready to request the ad from PubMatic:
Step 5: Receiving PMBannerAdViewDelegate Callbacks
PubMatic SDK provides
PMBannerAdViewDelegate to receive ad event callbacks.
Make sure you set the delegate for the
PMBannerAdView instance (step 2B above), before calling the
See PubMatic SDK Error Codes for a detailed description of the
PMError object used in the
To fully support all MRAID events please follow the steps in Rich Media (MRAID 2.0) Support.
Enable Auto Refresh
PubMatic iOS SDK provides the optional feature to auto refresh a banner ad after a specified interval. You can set the refresh interval in code using
self.adView.updateInterval = <#value in secs#> before calling the
loadRequest: method. Use an interval value within a range of 12 to 120 seconds.
Ad Refresh Behavior for Value of Update Intervals
|Integer value ( i ) in seconds||Banner Auto-refresh behavior|
|i <= 0||Ad will not refresh|
|i > 0 & i <= 12||Ad will refresh after every 12 seconds.|
|i > 12 & i <= 120||Ad will refresh after every i seconds|
|i > 120||Ad will refresh after every 120 seconds|
Multisize Ad Support
You can specify multiple sizes in an ad request. Then SSP/Exchange serves the ad with the creative that best fits into those sizes and returns greater CPMs. This flexibility makes a greater number of campaigns/creatives eligible for the current impression, which can lead to increased fill rate.
Get the size of the creative if you need to write your own logic to resize the ad slot. For example: