Banner/MREC Ads

Banner and MREC ads are rectangular, image-based ads designed to be integrated directly into an app's content.

Adding the Ad Placement (Ad Spot)

Add the Ad Placement AdSpot integration for the display unit, as well as the AdView Controller:

Java
// Spot integration for display square
InneractiveAdSpot mSpot = InneractiveAdSpotManager.get().createSpot();

// Adding the adview controller
InneractiveAdViewUnitController controller = new InneractiveAdViewUnitController();
mSpot.addUnitController(controller);

Adding Listeners

Add listeners for the controller and the spot.

Adding Event Listener for the Controller

The example below demonstrates how you would add an EventListener to receive Banner or MREC ad callbacks:

Java
controller.setEventsListener(new InneractiveAdViewEventsListener() {
    @Override
    public void onAdImpression(InneractiveAdSpot adSpot) {
        Log.i(TAG, "onAdImpression");
    }
    @Override
    public void onAdClicked(InneractiveAdSpot adSpot) {
        Log.i(TAG, "onAdClicked");
    }
    @Override
    public void onAdWillCloseInternalBrowser(InneractiveAdSpot adSpot) {
        Log.i(TAG, "onAdWillCloseInternalBrowser");
    }
    @Override
    public void onAdWillOpenExternalApp(InneractiveAdSpot adSpot) {
        Log.i(TAG, "onAdWillOpenExternalApp");
    }
    @Override //Since VAMP 7.2.0
    public void onAdEnteredErrorState(InneractiveAdSpot adSpot, AdDisplayError error) {
        Log.i(TAG, "onAdEnteredErrorState");
    }
});

The onAdEnteredErrorState callback is invoked when the WebView renderer processes crash. For banner/MREC ads, destroy the current ad and request a replacement when WebViewRendererProcessHasGoneError occurs.

Adding Request Listener for the Spot

The example below demonstrates how you would add a RequestListener for the Spot:

Fetching the Ad

The way in which the ad is fetched depends on the mediation type — Waterfall or SDK Bidding.

Fetching the Ad for Waterfall

In Waterfall mediation, use InneractiveAdRequest adRequest to request the ad:

After a successful ad request, use mSpot.isReady to confirm the ad is ready and controller.bindView(layout); to display.

Fetching the Ad for SDK Bidding

In SDK Bidding, DT Exchange must first generate a token for the Mediation SDK to use when identifying the request to server.

Use getBidderToken to generate a Bidder Token in a background thread:

Return type: java.lang.String. If an error occurs, the returned value is null.

If DT Exchange wins the auction, load the ad with the signaldata (adm) that was received from the server:

If the load is successful: public void onInneractiveSuccessfulAdRequest(InneractiveAdSpot inneractiveAdSpot) callback is invoked.

If the ad fails to load: public void onInneractiveFailedAdRequest(InneractiveAdSpot inneractiveAdSpot, InneractiveErrorCode inneractiveErrorCode) callback is invoked.

Displaying the Ad

Define the ad layout in your XML file:

After a successful ad request, use mSpot.isReady to confirm the ad is ready and controller.bindView(layout); to display the ad:

Releasing an Ad Placement

DT recommends releasing the allocated resources for ad display. For more information, see Releasing Ad Instance Resources.

Last updated