Inline ads, commonly referred to as “banners” or “rectangles”, are ad units that appear inline with other app content. Inline Ads are often found at the top or bottom of a mobile device’s screen while reading articles and searching through content. We recommend using inline ads on both smartphones and tablets in cases where the user is reading and/or interacting with content on the same screen for a period of time.
Integrating Inline Ad Placements
To add an inline ad to an application, import the required classes, instantiate an inline ad factory, load the ad, and attach it to the app’s view hierarchy.
1. Import the required classes
Import the following into the Android activity or iOS view controller that will contain the ad.
2. Create an inline ad factory
An instance of the inline ad factory is required to load an ad. The factory is created once, typically when the app’s activity or view controller is created.
Inline ad factory callbacks
The Inline ad factory callbacks communicate events related to ad loading, such as success/failure of an ad load or load/update of the cache. These are implemented as an interface (Android) and delegates (iOS). Please refer to the API documentation for Android and iOS for a complete list of available callbacks.
3. Load an ad
Prior to displaying an ad, it must be loaded as seen below.
Inline ad callbacks
The inline ad callbacks provide information about events related to the ad, such as click events, expand/collapse, resize, and errors. These are implemented as an interface (Android) and delegate methods (iOS). Please refer to the API documentation for Android and iOS for complete list of available callbacks.
4. Show the ad
After the ad is loaded, the ad factory will call back to the
onLoaded (Android) or
-didLoadInlineAd: (iOS) method with the ad. Each inline ad is provided as a view, and that view should be inserted at the appropriate place in the app’s view hierarchy. A common strategy is to set up a container view in the view hierarchy, so that the ad view can be easily added to that container.
For a complete example of implementing an Inline Ad within an app, please review the sample application.