Omni Unit Ads

Omni ads are a brand new ad unit type that gives our SDK publishers an entirely incremental revenue stream. Omni ads are unobtrusive videos and rich media creatives that float on top of your app content. You can customize where and when the omni ad is displayed to ensure that it doesn’t negatively impact user experience or cover important UI controls.

Prerequisites

Display an Omni ad in your app

Displaying an omni ad is a two-step process. First you should create and load your MobileFuseOmniAd unit, then when you’re ready, call the showAd() method to display the ad.

  • Create an Omni ad unit
  • Display the ad

Create an Omni ad unit

The MobileFuseOmniAd class provided by the MobileFuse SDK will handle the loading, display and interactivity of the omni ad. It is similar in implementation to MobileFuse interstitial ads.

First, create a new MobileFuseOmniAd unit and keep a reference to it within the Activity where you want to use it:

private MobileFuseOmniAd omniAd;

private void createOmniAd() {
    String placementId = "000000";
    omniAd = new MobileFuseOmniAd(this, placementId);
}
private var omniAd: MobileFuseOmniAd? = null

private fun createOmniAd() {
    val placementId = "000000"
    omniAd = MobileFuseOmniAd(this, placementId)
}

📘

Note

Ensure that the SDK has fully initialized before creating your ad units. You can use the onInitSuccess callback as a good place to set up your ad units.

Next, add a listener - the listener will allow you to receive events from the ad unit. The omni ad has some additional callbacks for omni ad specific events.

omniAd.setListener(new MobileFuseOmniAd.Listener(){
    @Override
    public void onAdClosed(){
        // The omni ad has been dismissed and closed
    }

    @Override
    public void onStateChange(@NonNull MobileFuseOmniAd.AdState newState){
        if(newState == MobileFuseOmniAd.AdState.FULL_SCREEN){
            // The omni ad is now rendering in full-screen mode, you should
            // mute any audio/pause your app
        }else if(newState == MobileFuseOmniAd.AdState.THUMBNAIL){
            // The omni ad is now rendering as a floating thumbnail, your
            // app should not be paused
        }
    }

    @Override
    public void onAdLoaded(){
        // Called when the ad has been loaded and is ready to be displayed
    }

    @Override
    public void onAdNotFilled(){
        // The server responded with no fill (no ad available)
    }

    @Override
    public void onAdRendered(){
        // Triggered when the ad is first shown to the user - you could 
    		// use this to ensure that the corner of the screen does not contain 
    		// content that may be hidden by the omni ad
    }

    @Override
    public void onAdClicked(){
        // Called when the user clicks the ad
    }

    @Override
    public void onAdExpired(){
        // This ad has expired and can no longer be displayed to the user - load a new ad
    }

    @Override
    public void onAdError(AdError adError){
        // An error occurred, examine the adError argument to determine the problem
    }
});

// You can also listen for mute/unmute events - these happen when the user manually 
// un-mutes the ad and you should ensure that your app is not playing music at the same time:
omniAd.setMuteChangedListener(new MuteChangedListener(){
    @Override
    public void onMutedChanged(boolean muted){
        if(muted){
            // The ad is muted, your app can play audio as normal
        }else{
            // The ad is playing sound - mute any music that your app is playing
        }
    }
});
omniAd.setListener(object : MobileFuseOmniAd.Listener {
    override fun onAdClosed() {
        // The omni ad has been dismissed and closed
    }

    override fun onStateChange(newState: MobileFuseOmniAd.AdState) {
        if (newState == MobileFuseOmniAd.AdState.FULL_SCREEN) {
            // The omni ad is now rendering in full-screen mode, you should
            // mute any audio/pause your app
        } else if (newState == MobileFuseOmniAd.AdState.THUMBNAIL) {
            // The omni ad is now rendering as a floating thumbnail, your
            // app should not be paused
        }
    }

    override fun onAdLoaded() {
        // Called when the ad has been loaded and is ready to be displayed
    }

    override fun onAdNotFilled() {
        // The server responded with no fill (no ad available)
    }

    override fun onAdRendered() {
        // Triggered when the ad is first shown to the user - you could 
    		// use this to ensure that the corner of the screen does not contain 
    		// content that may be hidden by the omni ad
    }

    override fun onAdClicked() {
        // Called when the user clicks the ad
    }

    override fun onAdExpired() {
        // This ad has expired and can no longer be displayed to the user - load a new ad
    }

    override fun onAdError(adError: AdError) {
        // An error occurred, examine the adError argument to determine the problem
    }
})

// You can also listen for mute/unmute events - these happen when the user manually 
// un-mutes the ad and you should ensure that your app is not playing music at the same time:
omniAd.setMuteChangedListener(MuteChangedListener { muted ->
    if (muted) {
        // The ad is muted, your app can play audio as normal
    } else {
        // The ad is playing sound - mute any music that your app is playing
    }
})

Finally, request that the ad is preloaded using the loadAd() method:

omniAd.loadAd();
omniAd.loadAd()

Display the ad

Once the omni ad has triggered the onAdLoaded callback, you can then call showAd() to start displaying the initial thumbnail state of the ad:

omniAd.showAd();
omniAd.showAd()

Optionally, you can specify the corner for the ad to be displayed in - this will default to bottom-right and should be set before calling showAd():

// Choose where to display the ad!
omniAd.showAd(MobileFuseOmniAd.Position.BOTTOM_LEFT);
omniAd.showAd(MobileFuseOmniAd.Position.BOTTOM_RIGHT);
omniAd.showAd(MobileFuseOmniAd.Position.TOP_LEFT);
omniAd.showAd(MobileFuseOmniAd.Position.TOP_RIGHT);
// Choose where to display the ad!
omniAd.showAd(MobileFuseOmniAd.Position.BOTTOM_LEFT)
omniAd.showAd(MobileFuseOmniAd.Position.BOTTOM_RIGHT)
omniAd.showAd(MobileFuseOmniAd.Position.TOP_LEFT)
omniAd.showAd(MobileFuseOmniAd.Position.TOP_RIGHT)

You can also use isLoaded() to check whether the ad is ready to be displayed.

if (omniAd.isLoaded()) {
    // The ad is ready to be displayed!
}
if (omniAd.isLoaded) {
    // The ad is ready to be displayed!
}