Integrate Smart Display SDK as a In-App Bidding partner

  1. In-App Bidding API:
    1. The SASBiddingManager class
    2. The SASBiddingManagerListener interface
    3. The SASBiddingAdResponse class
    4. The SASBiddingAdPrice class
  2. How to integrate In-App Bidding in your application:
    1. Banner format
    2. Interstitial format
    3. Rewarded Video format

In-App Bidding API

The SASBiddingManager class

The SASBiddingManager object is in charge of making the Inapp-Bidding calls to Smart servers and returning ads with their corresponding price.

The SASBiddingManager constructor requires 4 parameters, as described below:


/**
 * Constructor. Initializes the SASBiddingManager instance.
 *
 * @param adPlacement The placement that will be used for the bidding call.
 * @param formatType  The expected {@link SASBiddingFormatType} format type.
 * @param currency    The currency that will be used for the bidding call (must be a 3 letters string compliant with ISO 4217).
 * @param listener    The {@link SASBiddingManagerListener} that will handle the bidding call outcome.
 */
public SASBiddingManager(@NonNull Context context,
                         @NonNull SASAdPlacement adPlacement,
                         @NonNull SASBiddingFormatType formatType,
                         @NonNull String currency,
                         @NonNull SASBiddingManagerListener listener)

/**
* Constructor. Initializes the SASBiddingManager instance.
*
* @param adPlacement The placement that will be used for the bidding call.
* @param formatType  The expected {@link SASBiddingFormatType} format type.
* @param currency    The currency that will be used for the bidding call (must be a 3 letters string compliant with ISO 4217).
* @param listener    The {@link SASBiddingManagerListener} that will handle the bidding call outcome.
*/      
class SASBiddingManager(context: Context, 
                        adPlacement: SASAdPlacement,
                        formatType: SASBiddingFormatType,
                        currency: String,
                        listener: SASBiddingManagerListener)

Below is the list of all possible values of the SASBiddingFormatType enumeration:


/**
 * Unknown type
 */
UNKNOWN(-1),

/**
 * Banner type
 */
BANNER(0),

/**
 * Interstitial type
 */
INTERSTITIAL(1),

/**
 * Rewarded video type
 */
REWARDED_VIDEO(2);

Example of a SASBiddingManager instantation:


// Creation of the SASAdPlacement.
SASAdPlacement adPlacement = new SASAdPlacement(123, "456", 789, "targeting-string"); // replace site/page/format values with your own.

// Creation of a SASBiddingManagerListener instance to handle the bidding call outcome.
SASBiddingManagerListener biddingManagerListener = new SASBiddingManagerListener() {
  @Override
  void onBiddingManagerAdLoaded(@NonNull SASBiddingAdResponse biddingAdResponse) {
    // Code that will handle a successful loading of a bidding ad.
  }

  @Override
  void onBiddingManagerAdFailedToLoad(@NonNull Exception e) {
    // Code that will handle a failure during the loading.
  }
};

// Creation of the SASBiddingManager
SASBiddingManager biddingManager = new SASBiddingManager(currentAppContext, adPlacement, SASBiddingFormatType.BANNER, "EUR", biddingManagerListener);

// Creation of the SASAdPlacement.
val adPlacement = SASAdPlacement(123, "456", 789, "targeting-string") // replace site/page/format values with your own.

// Creation of a SASBiddingManagerListener instance to handle the bidding call outcome.
val biddingManagerListener = SASBiddingManagerListener {
  override fun onBiddingManagerAdLoaded(adResponse: SASBiddingAdResponse) {
    // Code that will handle a successful loading of a bidding ad.
  }

  override fun onBiddingManagerAdFailedToLoad(e: java.lang.Exception) {
    // Code that will handle a failure during the loading.
  }
}

// Creation of the SASBiddingManager
val biddingManager = SASBiddingManager(currentAppContext, adPlacement, SASBiddingFormatType.BANNER, "EUR", biddingManagerListener)

Once the SASBiddingManager object is created, you can request an ad simply by calling the load method:


  biddingManager.load();

  biddingManager.load()

The outcome of the bidding call will be handled by the SASBiddingManager passed at the creation of the SASBiddingManager as described below.

The SASBiddingManagerListener interface

The SASBiddingManagerListener is the interface that must be implemented by objects that will handle the bidding call outcome:


/**
 * Interface definition for a callback to be called when a bidding call on a {@link SASBiddingManager} succeeds or fails
 */
public interface SASBiddingManagerListener {
  /**
   * Method called when the bidding manager succeeded to load a bidding ad.
   * Note that it is executed on the main thread.
   */
  void onBiddingManagerAdLoaded(@NonNull SASBiddingAdResponse biddingAdResponse);

  /**
   * Method called when the bidding manager failed to load a bidding ad.
   * Note that it is executed on the main thread.
   */
  void onBiddingManagerAdFailedToLoad(@NonNull Exception e);
}

/**
* Interface definition for a callback to be called when a bidding call on a {@link SASBiddingManager} succeeds or fails
*/
interface SASBiddingManagerListener {
  /**
   * Method called when the bidding manager succeeded to load a bidding ad.
   * Note that it is executed on the main thread.
   */
  fun onBiddingManagerAdLoaded(biddingAdResponse: SASBiddingAdResponse)

  /**
   * Method called when the bidding manager failed to load a bidding ad.
   * Note that it is executed on the main thread.
   */
  fun onBiddingManagerAdFailedToLoad(e: Exception)
}

Although you have to pass a non null SASBiddingManagerListener object when instantiating a SASBiddingManager (for obvious callback reasons), you can still set another nullable SASBiddingManagerListener after creation by using the setBiddingManagerListener() method.
This is mainly to nullify the listener as a way to cancel any pending call.


// set the listener to null when you are not interested in the pending bidding call anymore,
// typically when you don't plan on using the SASBidderManager instance anymore
biddingManager.setBiddingManagerListener(null);

// set the listener to null when you are not interested in the pending bidding call anymore,
// typically when you don't plan on using the SASBidderManager instance anymore
biddingManager.setBiddingManagerListener(null)

If case of a failing bidding call, the SASBiddingManager instance will call the onBiddingManagerAdFailedToLoad() method passing the Exception object representing the reason of the failure.

In case of a successful bidding call, the SASBiddingManager instance will call the onBiddingManagerAdLoaded() method passing the SASBiddingAdResponse object representing the ad that won the bid. You will find more information about it in the section below.

The SASBiddingAdResponse class

The SASBiddingAdResponse is object containing the ad content to be displayed, along with its price, its format type and the placement it was delivered on.

To compare this ad with other partner's responses you will call the getBiddingAdPrice() method that returns a SASBiddingAdPrice object representing the CPM of the received ad. You will find more information about the SASBiddingAdPrice in the next section.

Should your competition select that SASBiddingAdResponse as the winning ad, you will pass this instance to banner, interstitial or rewarded video object to be actually displayed. For more information, please check the integration section.

The SASBiddingAdPrice class

A SASBiddingAdPrice instance is an object representing the price of a bidding ad. A price is composed of a CPM and a currency:


/**
 * @return the cpm of the bidding ad price.
 */
public double getCpm() {
  return cpm;
}

/**
 * @return the currency of the bidding ad price.
 */
public String getCurrency() {
  return currency;
}

/**
* @return the cpm of the bidding ad price.
*/
fun getCpm(): Double {
    return cpm
}

/**
* @return the currency of the bidding ad price.
*/
fun getCurrency(): String? {
    return currency
}

As mentioned in the SASBiddingManager section, the currency is a 3 letters string compliant with ISO 4217.

How to integrate In-App Bidding in your application:

1. Implementation of SASBiddingManagerListener

As seen previously, the SASBiddingManagerListener object will handle the outcome of the SASBiddingManager call.

If the call is successful, you will integrate the received SASBiddingAdResponse object in your competition. If the this ad wins the competition according to your criterias, you will display the ad using the loadAd(SASBiddingAdResponse adResponse) method of the SASBannerView class using a SASBiddingAdResponse object as parameter.

You can find more information about Smart Display SDK banner integration here.

Implementation example:


// Implementation of the bidding manager listener for a banner
SASBiddingManagerListener biddingManagerListener = new SASBiddingManagerListener() {
  @Override
  void onBiddingManagerAdLoaded(@NonNull SASBiddingAdResponse biddingAdResponse)
    // Retrieve the bidding ad price
    SASBiddingAdPrice biddingAdPrice = biddingAdResponse.getBiddingAdPrice();

    // Perform the bidding competition using biddingAdPrice.getCpm() and biddingAdPrice.getCurrency() methods.
    // We here assume Smart wins the competition

    // Load the SASBiddingAdResponse ad in a previously instantiated SASBannerView
    bannerView.loadAd(biddingAdResponse);
  }

  @Override
  void onBiddingManagerAdFailedToLoad(@NonNull Exception e) {
    // Smart did not return any bidding ad, proceed with your competition process
  }
};

// Implementation of the bidding manager listener for a banner
val biddingManagerListener = object: SASBiddingManagerListener {
  override fun onBiddingManagerAdLoaded(biddingAdResponse: SASBiddingAdResponse) {
    // Retrieve the bidding ad price
    val biddingAdPrice = biddingAdResponse.biddingAdPrice

    // Perform the bidding competition using biddingAdPrice.cpm and biddingAdPrice.currency properties.
    // We here assume Smart wins the competition

    // Load the SASBiddingAdResponse ad in a previously instantiated SASBannerView
    bannerView.loadAd(biddingAdResponse)
  }

  override fun onBiddingManagerAdFailedToLoad(e: Exception) {
    // Smart did not return any bidding ad, proceed with your competition process
  }
}

Now, you need to instantiate the SASBiddingManager object and perform the bidding call.

2. SASBiddingManager instantiation and bidding call

Instantiate your SASBiddingManager like described above:


// Create the ad placement
SASAdPlacement adPlacement = new SASAdPlacement(123, "456", 789, "targeting-string"); // Replace site/page/format with your own.

// Create the bidding manager object
SASBiddingManager biddingManager = new SASBiddingManager(context, adPlacement, SASBiddingFormatType.BANNER, "EUR", biddingManagerListener);

// Perform the bidding call
biddingManager.load();

// Create the ad placement
val adPlacement = SASAdPlacement(123, "456", 789, "targeting-string") // replace site/page/format values with your own.

// Create the bidding manager object
val biddingManager = SASBiddingManager(currentAppContext, adPlacement, SASBiddingFormatType.BANNER, "EUR", biddingManagerListener)

// Perform the bidding call
biddingManager.load()

Interstitial format

1. Implementation of SASBiddingManagerListener

As seen previously, the SASBiddingManagerListener object will handle the outcome of the SASBiddingManager call.

If the call is successful, you will integrate the received SASBiddingAdResponse object in your competition. If this ad wins the competition according to your criterias, you will instantiate a SASInterstitialManager using the SASBiddingAdResponse object as parameter. From there on, you will call the loadAd() method to actually prepare the SASBiddingAdResponse for display, and call the show() method upon interstitial loading.

You can find more information about Smart Display SDK interstitial integration here.

Implementation example:


// Implementation of the bidding manager listener for an interstitial
SASBiddingManagerListener biddingManagerListener = new SASBiddingManagerListener() {
  @Override
  void onBiddingManagerAdLoaded(@NonNull SASBiddingAdResponse biddingAdResponse)
    // Retrieve the bidding ad price
    SASBiddingAdPrice biddingAdPrice = biddingAdResponse.getBiddingAdPrice();

    // Perform the bidding competition using biddingAdPrice.getCpm() and biddingAdPrice.getCurrency() methods.
    // We here assume Smart wins the competition

    // Instantiate a new SASInterstitialManager with the SASBiddingAdResponse
    SASInterstitialManager interstitialManager = new SASInterstitialManager(context, biddingAdResponse);

    // Set the interstitialManager's listener, with a listener previously implemented
    interstitialManager.setInterstitialListener(interstitialListener);

    // Load the interstitial. The interstitialListener onInterstitialAdLoaded() method will be called
    // when the insterstitial is ready to be shown. You can then call the show() method from there on.
    interstitialManager.loadAd()
  }

  @Override
  void onBiddingManagerAdFailedToLoad(@NonNull Exception e) {
    // Smart did not return any bidding ad, proceed with your competition process
  }
};

// Implementation of the bidding manager listener for an interstitial
val biddingManagerListener = object: SASBiddingManagerListener {
  override fun onBiddingManagerAdLoaded(adResponse: SASBiddingAdResponse) {
    // Retrieve the bidding ad price
    val biddingAdPrice = biddingAdResponse.biddingAdPrice

    // Perform the bidding competition using biddingAdPrice.cpm and biddingAdPrice.currency properties.
    // We here assume Smart wins the competition

    // Instantiate a new SASInterstitialManager with the SASBiddingAdResponse
    val interstitialManager = SASInterstitialManager(context, biddingAdResponse)

    // Set the interstitialManager's listener, with a listener previously implemented
    interstitialManager.interstitialListener = interstitialListener

    // Load the interstitial. The interstitialListener onInterstitialAdLoaded() method will be called
    // when the insterstitial is ready to be shown. You can then call the show() method from there on.
    interstitialManager.loadAd()
  }

  override fun onBiddingManagerAdFailedToLoad(e: Exception) {
    // Smart did not return any bidding ad, proceed with your competition process
  }
}

Now, you need to instantiate the SASBiddingManager object and perform the bidding call.

2. SASBiddingManager instantiation and bidding call

Instantiate your SASBiddingManager like described above:


// Create the ad placement
SASAdPlacement adPlacement = new SASAdPlacement(123, "456", 789, "targeting-string"); // Replace site/page/format with your own.

// Create the bidding manager object
SASBiddingManager biddingManager = new SASBiddingManager(context, adPlacement, SASBiddingFormatType.INTERSTITIAL, "EUR", biddingManagerListener);

// Perform the bidding call
biddingManager.load();

// Create the ad placement
val adPlacement = SASAdPlacement(123, "456", 789, "targeting-string") // Replace site/page/format with your own.

// Create the bidding manager object
val biddingManager = SASBiddingManager(context, adPlacement, SASBiddingFormatType.INTERSTITIAL, "EUR", biddingManagerListener)

// Perform the bidding call
biddingManager.load()

Rewarded Video format

1. Implementation of SASBiddingManagerListener

As seen previously, the SASBiddingManagerListener object will handle the outcome of the SASBiddingManager call.

If the call is successful, you will integrate the received SASBiddingAdResponse object in your competition. If this ad wins the competition according to your criterias, you will instantiate a SASRewardedVideoManager using the SASBiddingAdResponse object as parameter. From there on, you will call the loadRewardedVideo() method to actually prepare the SASBiddingAdResponse for display, and call showRewardedVideo() method upon rewarded video loading.

You can find more information about Smart Display SDK rewarded video integration here.

Implementation example:


// Implementation of the bidding manager listener for a rewarded video
SASBiddingManagerListener biddingManagerListener = new SASBiddingManagerListener() {
  @Override
  void onBiddingManagerAdLoaded(@NonNull SASBiddingAdResponse biddingAdResponse)
    // Retrieve the bidding ad price
    SASBiddingAdPrice biddingAdPrice = biddingAdResponse.getBiddingAdPrice();

    // Perform the bidding competition using biddingAdPrice.getCpm() and biddingAdPrice.getCurrency() methods.
    // We here assume Smart wins the competition

    // Instantiate a new SASRewardedVideoManager with the SASBiddingAdResponse
    SASRewardedVideoManager rewardedVideoManager = new SASRewardedVideoManager(context, biddingAdResponse);

    // Set the rewardedVideoManager's listener, with a listener previously implemented
    rewardedVideoManager.setRewardedVideoListener(rewardedVideoListener);

    // Load the rewarded video. The rewardedVideoListener onRewardedVideoAdLoaded() method will be called
    // when the rewarded video is ready to be shown. You can then call the showRewardedVideo() method from there on.
    rewardedVideoManager.loadRewardedVideo()
  }

  @Override
  void onBiddingManagerAdFailedToLoad(@NonNull Exception e) {
    // Smart did not return any bidding ad, proceed with your competition process
  }
};

// Implementation of the bidding manager listener for a rewarded video
val biddingManagerListener = object: SASBiddingManager.SASBiddingManagerListener {
  override fun onBiddingManagerAdLoaded(biddingAdResponse: SASBiddingAdResponse) {
    // Retrieve the bidding ad price
    val biddingAdPrice = biddingAdResponse.biddingAdPrice

    // Perform the bidding competition using biddingAdPrice.getCpm() and biddingAdPrice.getCurrency() methods.
    // We here assume Smart wins the competition

    // Instantiate a new SASRewardedVideoManager with the SASBiddingAdResponse
    val rewardedVideoManager = SASRewardedVideoManager(context, biddingAdResponse)

    // Set the rewardedVideoManager's listener, with a listener previously implemented
    rewardedVideoManager.rewardedVideoListener = rewardedVideoListener

    // Load the rewarded video. The rewardedVideoListener onRewardedVideoAdLoaded() method will be called
    // when the rewarded video is ready to be shown. You can then call the showRewardedVideo() method from there on.
    rewardedVideoManager.loadRewardedVideo()
  }

  override fun  onBiddingManagerAdFailedToLoad(e: Exception) {
    // Smart did not return any bidding ad, proceed with your competition process
  }
}

Now, you need to instantiate the SASBiddingManager object and perform the bidding call.

2. SASBiddingManager instantiation and bidding call

Instantiate your SASBiddingManager like described above:


// Create the ad placement
SASAdPlacement adPlacement = new SASAdPlacement(123, "456", 789, "targeting-string"); // Replace site/page/format with your own.

// Create the bidding manager object
SASBiddingManager biddingManager = new SASBiddingManager(context, adPlacement, SASBiddingFormatType.REWARDED_VIDEO, "EUR", biddingManagerListener);

// Perform the bidding call
biddingManager.load();

// Create the ad placement
val adPlacement = SASAdPlacement(123, "456", 789, "targeting-string") // replace site/page/format values with your own.

// Create the bidding manager object
val biddingManager = SASBiddingManager(currentAppContext, adPlacement, SASBiddingFormatType.REWARDED_VIDEO, "EUR", biddingManagerListener)

// Perform the bidding call
biddingManager.load()