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.
InMobiAudio
object before SDK initialization throws an error.Import the headers and declare an Audio instance in your ViewController.h
file or import the frameworks and declare an Audio instance in your ViewController.swift
file. Your ViewController
header file should look like:
import UIKit
import InMobiSDK
class ViewController: UIViewController, IMAudioDelegate {
var audioAd: IMAudio?
}
Instantiate the audio object. Your ViewController.m
file should look like this:
override func viewDidLoad() {
super.viewDidLoad()
let audioAd = IMAudio(frame: CGRect(x: 0, y: 0, width: 70, height: 70), placementId: "<placementId>", delegate: self)
audioAd.load()
self.view.addSubview(audioAd)
}
To show an audio ad, call show()
on the InMobiAudio
instance, after SDK generates the audioAdDidFinishLoading
event.
func audioAdDidFinishLoading(_ audioAd: IMAudio) {
audioAd.show()
}
If you want to listen to key events in the audio ad lifecycle, you can implement the IMAudioDelegate
method. A sample implementation is shown below.
func audioAdDidFinishLoading(_ audioAd: IMAudio) {}
func audioAdDidBecomeVisible(_ audioAd: IMAudio) {}
func audioAd(_ audioAd: IMAudio, didReceiveWithMetaInfo info: IMAdMetaInfo) {}
func audioAd(_ audioAd: IMAudio, didFailToLoadWithError error: IMRequestStatus) {}
func audioAd(_ audioAd: IMAudio, didFailToShowWithError error: IMRequestStatus) {}
func audioAdImpressed(_ audioAd: IMAudio) {}
func audioAd(_ audioAd: IMAudio, didInteractWithParams params: [String: Any]?) {}
func audioAdWillPresentScreen(_ audioAd: IMAudio) {}
func audioAdDidPresentScreen(_ audioAd: IMAudio) {}
func audioAdWillDismissScreen(_ audioAd: IMAudio) {}
func audioAdDidDismissScreen(_ audioAd: IMAudio) {}
func userWillLeaveApplicationFromAudioAd(_ audioAd: IMAudio) {}
func audioAd(_ audioAd: IMAudio, rewardActionCompletedWithRewards rewards: [String: Any]) {}
func audioAd(_ audioAd: IMAudio, audioStatusChanged status: IMAudioStatus) {
switch status:
case .playing: break
case .paused: break
case .completed: break
}
The bid value can be accessed from the IMAdMetaInfo
object’s getBid
function. You can find more information in the bidInfo
property.
You can release the resources after showing an audio ad by calling cancel.
audioAd.cancel()
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 rewardActionCompletedWithRewards
event for Rewarded ads. However, you can retain the flexibility to determine the timing of user rewards using various event callbacks.
func audioAd(_ audioAd: IMAudio, rewardActionCompletedWithRewards rewards: [String: Any]) {
// Do reward operation
}
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.