Banner/MREC Ads
HyprMX supports Banner/MREC and Audio Banner Ad Units. This guide shows how to display these Banner Ads in your application.
What are Banner/MREC Ads?
Banner or Medium Rectangle (MREC) Ad Units display a rectangular creative within an app. They occupy a portion of the app layout and stay on the screen as the users interact with the app. Refer to the Ad Size section for a list of supported ad sizes for Banner/MREC Ad Units.
What are Audio Banner Ads?
Audio Banner Ad Units display a rectangular creative with an accompanying audio component within an app. HyprMX provides an optional interface to receive callbacks notifying your application of interruptions to the Audio Stream by an Audio Banner Ad and when the Ad audio is finished to clear the interruption. All sizes supported for Banner/MREC Ads are supported in Audio Banner Ads.
Refresh Requirements
An Audio Banner Ad must remain on screen for the duration of the audio playback. To ensure the banner placement is not refreshed until the audio is complete, please set the refresh interval in your mediator's dashboard to 30 seconds or greater.
How to Display Banner Ads
Integrate & Initialize HyprMX
Before you start, make sure you have correctly integrated and initialized the HyprMX SDK. To integrate and initialize HyprMX, see our Setup Guide.
Initialize a BannerView
BannerViews are initialized with their placement name and ad size.
Placement Name
HyprMX utilizes placements to load and display an ad. Placements are used to represent a point in your application's workflow where you'd like to show an ad and placement names are a string that identifies individual banner placements in your application.
If you don't have your placement information, please reach out to your account manager to configure your banner placements. In return, they will provide the names of the new placements.
Ad Size
Banners are initialized using one of the pre-defined ad sizes.
To initialize your banner view you can use XML, code integration, or a combination of the two.
Code Initialization
When constructing a new banner view, the activity context must be used.
XML Initialization
The banner view can be initialized in XML as seen below with the attributes app:hyprMXAdSize
and app:hyprMXPlacementName
.
Code Setting of Name/Size
Adding Banners to your View
Add your BannerView to your View using XML or code and configure its layout to match your requested ad size.
Example Using XML:
Example using Code:
Loading Advertisements
To load a banner ad:
Your bannerView will load an ad and render it in its view. To receive ad load success and other lifecycle callbacks, implement the HyprMXBannerListener
and set the listener on your bannerView.
Setting a HyprMXBannerListener (Optional)
To receive lifecycle callbacks on your HyprMXBannerView
, implement the HyprMXBannerListener
.
Implement the HyprMXBannerListener:
Audio Banner Ad Event Callbacks (Optional)
Setting an Audio Listener on HyprMX
To receive audio event callbacks, implement the HyprMXIf.HyprMXAudioAdListener
interface and set your listener object to HyprMX.setAudioAdListener(this)
.
Handling Interruptions
When an Audio Banner Ad begins playing, you will receive a onAdAudioStart
callback from your AudioChangeDelegate
. You should use this callback to pause your application's current audio players.
Clearing Interruptions
When an Audio Banner Ad has completed playback, you will receive a onAdAudioEnd
callback from your AudioChangeDelegate
. You should use this callback to resume the AudioSession within your app and resume your Application's audio players.
Updating Ad Size / Reloading
You can reload another banner at any time by calling loadAd()
on the bannerView. You can also update your adSize
before loading a new ad by updating the bannerView.adSize
property.
Destroying
When the hosting Activity
or Fragment
is destroyed, or you are done with the banner view and it is no longer visible and attached, be sure to also destroy the HyprMXBannerView
by calling:
Last updated