Enhance your app's monetization potential with InMobi's cutting-edge Audio Ads feature. With InMobi's SDK support for Audio Ads, you can seamlessly integrate high-quality, targeted audio advertisements into your app's audio content. Engage your users with relevant and captivating audio messages that fit seamlessly within their experience.
Ensure you have updated the InMobi Android SDK to version 10.5.7 or above. Creating an InMobiAudio
object before SDK initialization throws an error.
To add an Audio ad in the Android code, create an InMobiAudio
instance:
val inmobiAudioAd = InMobiAudio(this, AUDIO_PLACEMENT_ID);
You can create an audio container anywhere on the screen with a 70p x 70px size, preferably, and add it to the view hierarchy:
val adContainer = findViewById<RelativeLayout>(<ad-container-id>)
adContainer.removeAllViews()
adContainer.addView(inmobiAudioAd)
inmobiAudioAd.setAudioSize(70, 70)
To request an interstitial ad, call the load()
method on the InMobiAudio
instance:
inmobiAudioAd.load()
If the onAdLoadSucceeded
event is generated, you can show the ad after this by calling show()
on the InMobiAudio
instance.
load()
is called with every InMobiAudio
instance.load()
.To show an audio ad, call show()
on the InMobiAudio instance after the onAdLoadSucceeded
the SDK has generated an event.
inmobiAudioAd.setListener(object: AudioAdEventListener(){
override fun onAdLoadSucceeded(p0: InMobiAudio?, p1: AdMetaInfo) {
super.onAdLoadSucceeded(p0, p1)
inmobiAudioAd.show();
}
}
If you want to listen to key events in the audio ad lifecycle, you can implement the AudioAdEventListener interface. A sample implementation is shown below.
val audioAdEventListener = object : AudioAdEventListener() {
/**
* Called to notify that an ad was received successfully but is not ready to be ayed yet.
*
* @param ad Represents the ad which was loaded or preloaded
* @param info Represents the ad meta information
*/
override fun onAdFetchSuccessful(ad: InMobiAudio, info: AdMetaInfo) {
}
/**
* Called to notify that an ad preload has failed.
*
* @param ad Represents the [InMobiAudio] ad which was preloaded
* @param status Represents the [InMobiAdRequestStatus] status containing error reason
*/
override fun onAdFetchFailed(ad: InMobiAudio, status: InMobiAdRequestStatus) {
}
/**
* Called to notify that an ad was successfully loaded and is ready to be displayed.
*
* @param ad Represents the ad which was loaded
* @param info Represents the ad meta information
*/
override fun onAdLoadSucceeded(ad: InMobiAudio, info: AdMetaInfo) {
}
/**
* Called to notify that a request to load an ad failed.
*
* @param ad Represents the ad which failed to load
* @param status Represents the [InMobiAdRequestStatus] status containing error reason
*/
override fun onAdLoadFailed(ad: InMobiAudio, status: InMobiAdRequestStatus) {
}
/**
* Called to notify that the banner ad has expanded
*
* @param ad Represents the [InMobiAudio] ad which was expanded
*/
override fun onAdDisplayed(ad: InMobiAudio) {
}
/**
* Called to indicate that a request to show an ad (by calling [InMobiAudio.show]
* failed. You should call [InMobiAudio.load] to request for a fresh ad.
*
* @param ad Represents the [InMobiAudio] ad which failed to show
*/
override fun onAdDisplayFailed(ad: InMobiAudio) {
}
/**
* Called to notify that inmobi has logged an impression for the ad
*
* @param ad Represents the ad which was impressed
*/
override fun onAdImpression(ad: InMobiAudio) {
}
/**
* Called to notify that the Audio status has changed
*
* @param ad Represents the [InMobiAudio] ad
* @param audioStatus Represents the [AudioStatus] of the current playing ad
*/
override fun onAudioStatusChanged(ad: InMobiAudio, audioStatus: AudioStatus) {
}
/**
* Called to notify that the user interacted with the ad.
*
* @param ad Represents the ad on which user clicked
* @param params Represents the click parameters
*/
override fun onAdClicked(ad: InMobiAudio, params: Map<Any, Any>) {
}
/**
* Called to notify that a reward was unlocked.
*
* @param ad Represents the [InMobiAudio] ad for which rewards was unlocked
* @param rewards Represents the rewards unlocked
*/
override fun onUserLeftApplication(ad: InMobiAudio) {
}
/**
* Called to notify that the User is about to return to the application after closing d.
*
* @param ad Represents the [InMobiAudio] ad which was closed
*/
override fun onAdDismissed(ad: InMobiAudio) {
}
}
audioAd.setListener(audioAdEventListener)
The bid value can be accessed from the AdMetaInfo
object’s bid field.
You can release the resources after showing an audio ad by calling destroy. You may call the function on receiving AudioStatus
.Completed in onAudioStatusChanged
function callback in the listener.
inmobiAudioAd.destroy()
The implementation for Rewarded Audio Icon ads closely resembles that of Audio Icons.
You are expected to present a prompt to users, seeking their opt-in prior to displaying the rewarded audio icon ad. The InMobi SDK also offers the onRewardsUnlocked
event for Rewarded ads. However, you can retain the flexibility to determine the timing of user rewards using various event callbacks.
inmobiAudioAd.setListener(object: AudioAdEventListener(){
override fun onRewardsUnlocked(ad: InMobiAudio, rewards: Map<Any, Any>) {
super.onRewardsUnlocked(ad, rewards)
// pass rewards to the user
}
}
Using sandbox ads, you can assess the placement and refine the user experience. This involves configuring the placement in Test Mode, setting it as 'Global' within the placement settings. It's important to ensure that you set the device volume to a sufficient level to ensure ad playback.
For those employing manual SDK integration, it's imperative to initialize the InMobi SDK within the mediation debugger to ensure seamless operation and accurate evaluation.
By installing this SDK update, you agree that your Children Privacy Compliance setting remains accurate or that you will update that setting, whenever there is a change in your app's audience. You may update the app's Children Privacy Compliance settings at https://publisher.inmobi.com/my-inventory/app-and-placements.