Documentation

Interstitial

InterstitialRequest

Setup InterstitialRequest builder

To create a InterstitialRequest instance, you need to create a InterstitialRequest.Builder instance, set all the necessary parameters and call build on it.

TypeDescription
AdContentType.AllFlag to request both Video and Static ad content types.
AdContentType.StaticFlag to request Static ad content type only.
AdContentType.VideoFlag to request Video ad content type only.

πŸ“˜

By default AdContentType is AdContentType.All

InterstitialRequest.Builder interstitialRequestBuilder = new InterstitialRequest.Builder()
        .setAdContentType(...) // Set AdContentType
        .setTargetingParams(...) // Set TargatingParams instance
        .setPriceFloorParams(...) // Set price floor parameters
        .setSessionAdParams(...) // Set SessionAdParams instance
        .setLoadingTimeOut(...) // Set loading timeout in milliseconds
        .setPlacementId(...) // Set placement id
val interstitialRequestBuilder = InterstitialRequest.Builder()
        .setAdContentType(...) // Set AdContentType
        .setTargetingParams(...) // Set TargatingParams instance
        .setPriceFloorParams(...) // Set price floor parameters
        .setSessionAdParams(...) // Set SessionAdParams instance
        .setLoadingTimeOut(...) // Set loading timeout in milliseconds
        .setPlacementId(...) // Set placement id

Set AdRequestListener

Set the InterstitialRequest.AdRequestListener instance to theInterstitialRequest.Builder instance.

interstitialRequestBuilder.setListener(new InterstitialRequest.AdRequestListener() {
    
    /**
     * Called when InterstitialRequest was requested successfully
     *
     * @param request       - InterstitialRequest instance
     * @param auctionResult - AuctionResult info
     */
    @Override
    public void onRequestSuccess(@NonNull InterstitialRequest request,
                                 @NonNull AuctionResult auctionResult) {

    }

    /**
     * Called when InterstitialRequest request failed
     *
     * @param request - InterstitialRequest instance
     * @param error   - BMError with additional info about error
     */
    @Override
    public void onRequestFailed(@NonNull InterstitialRequest request,
                                @NonNull BMError error) {
        
    }

    /**
     * Called when InterstitialRequest expired
     *
     * @param request - InterstitialRequest instance
     */
    @Override
    public void onRequestExpired(@NonNull InterstitialRequest request) {
        
    }
  
});
interstitialRequestBuilder.setListener(object : InterstitialRequest.AdRequestListener {
    
    /**
     * Called when InterstitialRequest was requested successfully
     *
     * @param request       - InterstitialRequest instance
     * @param auctionResult - AuctionResult info
     */
    override fun onRequestSuccess(request: InterstitialRequest,
                                  auctionResult: AuctionResult) {

    }

    /**
     * Called when InterstitialRequest request failed
     *
     * @param request - InterstitialRequest instance
     * @param error   - BMError with additional info about error
     */
    override fun onRequestFailed(request: InterstitialRequest,
                                 error: BMError) {

    }

    /**
     * Called when InterstitialRequest expired
     *
     * @param request - InterstitialRequest instance
     */
    override fun onRequestExpired(request: InterstitialRequest) {

    }
  
})

🚧

Note

AdRequestListener callbacks are delivered on the background thread, not the main one.

Build InterstitialRequest

When all the necessary parameters are set, call build on the InterstitialRequest.Builder instance:

InterstitialRequest interstitialRequest = interstitialRequestBuilder.build();
val interstitialRequest = interstitialRequestBuilder.build()

❗️

Keep ad request

You need to keep reference to InterstitialRequest before calling InterstitialRequest#request, otherwise, it is possible it will be cleared by Garbage Collector and callbacks won’t be triggered.

Request InterstitialRequest

When you need to request an ad and get an AuctionResult, call request on the InterstitialRequest instance.

interstitialRequest.request(...);
interstitialRequest.request(...)

πŸ“˜

When you made an in-house meditation and you decided that an advertisement from BidMachine will be shown - call interstitialRequest.notifyMediationWin, if BidMachine lost in mediation - call interstitialRequest.notifyMediationLoss

Destroy InterstitialRequest

Destroy the InterstitialRequest instance if you don't need it anymore.

interstitialRequest.destroy();
interstitialRequest.destroy()

❗️

Don't destroy the InterstitialRequest instance, if it will be used for load the InterstitialAd instance or if the InterstitialAd instance loaded with the InterstitialRequest instance has not been shown yet.

Otherwise, ad will not work correctly, which can affect a lower display rate, fill rate, rendering errors, and as a result - lower revenue.

InterstitialAd

Load InterstitialAd

When you would like to load and display requested Ads:

  • Make sure that the InterstitialRequest instance have AuctionResult. It's mean ads requested successfully.
interstitialRequest.getAuctionResult() != null
interstitialRequest.auctionResult != null
  • Make sure that theInterstitialRequest instance not expired.
!interstitialRequest.isExpired()
!interstitialRequest.isExpired

Before execute load on the InterstitialAd instance set the InterstitialListener instance:

InterstitialAd interstitialAd = new InterstitialAd(...);
interstitialAd.setListener(new InterstitialListener() {
    
    /**
     * Called when Ad was loaded and ready to be displayed
     *
     * @param ad - InterstitialAd instance
     */
    @Override
    public void onAdLoaded(@NonNull InterstitialAd ad) {

    }

    /**
     * Called when Ad failed to load
     *
     * @param ad    - InterstitialAd instance
     * @param error - BMError with additional info about error
     */
    @Override
    public void onAdLoadFailed(@NonNull InterstitialAd ad,
                               @NonNull BMError error) {

    }

    /**
     * Called when Ad Impression has been tracked
     *
     * @param ad - InterstitialAd instance
     */
    @Override
    public void onAdImpression(@NonNull InterstitialAd ad) {

    }
  
    /**
     * Called when Ad show failed
     *
     * @param ad    - InterstitialAd instance
     * @param error - BMError with additional info about error
     */
    @Override
    public void onAdShowFailed(@NonNull InterstitialAd ad,
                               @NonNull BMError error) {
    
    }
      
    /**
     * Called when Ad has been clicked
     *
     * @param ad - InterstitialAd instance
     */
    @Override
    public void onAdClicked(@NonNull InterstitialAd ad) {

    }
  
    /**
     * Called when Ad was closed (e.g - user click close button)
     *
     * @param ad       - InterstitialAd instance
     * @param finished - Value for indicated, if ads was finished (e.g - video playing finished)
     */
    @Override
    public void onAdClosed(@NonNull InterstitialAd ad,
                           boolean finished) {
    
    }

    /**
     * Called when Ad expired
     *
     * @param ad - InterstitialAd instance
     */
    @Override
    public void onAdExpired(@NonNull InterstitialAd ad) {

    }
  
});
interstitialAd.load(interstitialRequest);
val interstitialAd = InterstitialAd(...)
interstitialAd.setListener(object : InterstitialListener {
    
    /**
     * Called when Ad was loaded and ready to be displayed
     *
     * @param ad - InterstitialAd instance
     */
    override fun onAdLoaded(ad: InterstitialAd) {

    }

    /**
     * Called when Ad failed to load
     *
     * @param ad    - InterstitialAd instance
     * @param error - BMError with additional info about error
     */
    override fun onAdLoadFailed(ad: InterstitialAd,
                                error: BMError) {

    }

    /**
     * Called when Ad Impression has been tracked
     *
     * @param ad - InterstitialAd instance
     */
    override fun onAdImpression(ad: InterstitialAd) {

    }
    
    /**
     * Called when Ad show failed
     *
     * @param ad    - InterstitialAd instance
     * @param error - BMError with additional info about error
     */
    override fun onAdShowFailed(ad: InterstitialAd,
                                error: BMError) {
    
    }
      
    /**
     * Called when Ad has been clicked
     *
     * @param ad - InterstitialAd instance
     */
    override fun onAdClicked(ad: InterstitialAd) {

    }
  
    /**
     * Called when Ad was closed (e.g - user click close button)
     *
     * @param ad       - InterstitialAd instance
     * @param finished - Value for indicated, if ads was finished (e.g - video playing finished)
     */
    override fun onAdClosed(ad: InterstitialAd,
                            finished: Boolean) {
    
    }

    /**
     * Called when Ad expired
     *
     * @param ad - InterstitialAd instance
     */
    override fun onAdExpired(ad: InterstitialAd) {

    }
  
})
interstitialAd.load(interstitialRequest)

Use onAdLoaded callback to determine the possibility of displaying

Show InterstitialAd

Before displaying, check if the InterstitialAd instance can be displayed:

interstitialAd.canShow();
interstitialAd.canShow()

To display the InterstitialAd instance, you just need to execute show.

interstitialAd.show();
interstitialAd.show()

Destroy InterstitialAd

After ad was successful shown and no longer needed, it can be destroyed.

interstitialAd.destroy();
interstitialAd.destroy()

πŸ“˜

Sample

You can find code examples written in Java and Kotlin: Github Interstitial