# iOS > In-App Bidding as Bidder

Source: https://help-display-sdk.equativ.com/ios/inappbidding.html

---

## Overview

Go to the [general In-App Bidding article](https://help-display-sdk.equativ.com/inappbidding.html.md) to have more information.

## In-App Bidding APIs

### The __SASBiddingManager__ class

The [`SASBiddingManager`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingManager.html) object is in charge of making the In-app Bidding calls to Equativ SSP and returning ads with their corresponding price.

The [`SASBiddingManager`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingManager.html) constructor requires 3 parameters, as described below:

```swift
/**
* @param adPlacement The ad placement used to load the ad.
* @param formatType The format type of the requested bidding ad.
* @param currency The currency that must be used for the price of the bidding ad.
*/
init(adPlacement: SASAdPlacement, formatType: SASBiddingAdFormatType, currency: SASBiddingCurrency)
```

Once the [`SASBiddingManager`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingManager.html) object is created, you can request an ad simply by calling the `loadAd` method.

The outcome of the bidding call will be handled by the set [`SASBiddingManagerDelegate`](https://help-display-sdk.equativ.com/ios/API/Protocols/SASBiddingManagerDelegate.html) as described below.

### The __SASBiddingManagerDelegate__ protocol

The [`SASBiddingManagerDelegate`](https://help-display-sdk.equativ.com/ios/API/Protocols/SASBiddingManagerDelegate.html) is the protocol that must be implemented by objects responsible for handling the outcome of bidding ad calls.

In case of a failing bidding call, the [`SASBiddingManagerDelegate`](https://help-display-sdk.equativ.com/ios/API/Protocols/SASBiddingManagerDelegate.html) instance will call the `biddingManager:didFailToLoadWithError:` method,
passing the `NSError` object representing the reason of the failure.

In case of successful bidding call, the [`SASBiddingManagerDelegate`](https://help-display-sdk.equativ.com/ios/API/Protocols/SASBiddingManagerDelegate.html) instance will call the `biddingManager:didLoadWithBiddingAdResponse:`
method, passing the [`SASBiddingAdResponse`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingAdResponse.html) object representing the bid from Equativ platform. You will find more information about it in the section below.

### The __SASBiddingAdResponse__ model

The [`SASBiddingAdResponse`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingAdResponse.html) is a model representing a bid that contains 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 responses from other partners, you will use the `price` property, which is an instance of [`SASBiddingAdPrice`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingAdPrice.html) model, representing the CPM of the received ad. For more details about the [`SASBiddingAdPrice`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingAdPrice.html) model, please refer to the [API documentation](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingAdPrice.html).

## How to integrate **Equativ Display SDK** as bidder in your application

### Banner format

##### 1. __SASBannerView__ integration

You will find more information about **Equativ Display SDK** Banner integration [here](https://help-display-sdk.equativ.com/ios/integration/banner.html.md).

##### 2. Implementation of __BiddingManagerListener__

As seen previously, the [`SASBiddingManagerDelegate`](https://help-display-sdk.equativ.com/ios/API/Protocols/SASBiddingManagerDelegate.html) object will handle the outcome of the [`SASBiddingManager`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingManager.html) call.

If the call is successful, you will integrate the received [`SASBiddingAdResponse`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingAdResponse.html) object in your competition. If this ad wins the competition according to your criteria, you will display the ad using the [`loadAd(with biddingAdResponse: SASBiddingAdResponse)`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBannerView.html#/c:objc(cs)SASBannerView(im)loadAdWithBiddingAdResponse:) method of the [`SASBannerView`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBannerView.html) class using the received [`SASBiddingAdResponse`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingAdResponse.html) instance as parameter.

You __can not__ call the `loadAd(with biddingAdResponse: SASBiddingAdResponse)` method on the [`SASInterstitialManager`](https://help-display-sdk.equativ.com/ios/API/Classes/SASInterstitialManager.html) once the `show` method was successfully called. Indeed, once the interstitial ad was displayed, the [`SASBiddingAdResponse`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingAdResponse.html) associated with the [`SASInterstitialManager`](https://help-display-sdk.equativ.com/ios/API/Classes/SASInterstitialManager.html) will be marked as 'consumed' and can not be either loaded or shown again.

Implementation example:
```swift
// MARK: - Bidding manager delegate

func biddingManager(_ biddingManager: SASBiddingManager, didFailToLoad error: any Error) {
    // Equativ did not return any bidding ad, proceed with your competition process
}

func biddingManager(_ biddingManager: SASBiddingManager, didLoadWith biddingAdResponse: SASBiddingAdResponse) {
    // Retrieve the bidding ad price
    let biddingAdPrice = biddingAdResponse.price

    // Perform the bidding competition using biddingAdPrice.cpm and biddingAdPrice.currency properties.
    // Here, we assume Equativ wins the competition

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

##### 3. __SASBiddingManager__ instantiation and bidding call

Instantiate your [`SASBiddingManager`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingManager.html) like so:
```swift
// Create the ad placement
let adPlacement = SASAdPlacement(siteId: 123, pageId: 456, formatId: 789) // Replace with your own ad placement

// Create the bidding manager object
let biddingManager = SASBiddingManager(adPlacement: adPlacement, formatType: .banner, currency: .EUR)

// Set previously created listener
biddingManager.delegate = self

// Perform the bidding call
biddingManager.loadAd()
```

### Interstitial format

##### 1. __SASInterstitialManager__ integration

You will find more information about **Equativ Display SDK** Interstitial integration [here](https://help-display-sdk.equativ.com/ios/integration/interstitial.html.md).

##### 2. Implementation of __BiddingManagerListener__

As seen previously, the [`SASBiddingManagerDelegate`](https://help-display-sdk.equativ.com/ios/API/Protocols/SASBiddingManagerDelegate.html) object will handle the outcome of the [`SASBiddingManager`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingManager.html) call.

If the call is successful, you will integrate the received [`SASBiddingAdResponse`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingAdResponse.html) object in your competition. If this ad wins the competition according to your criteria, you will display by using the right initializer [`initWithBiddingAdResponse:`](https://help-display-sdk.equativ.com/ios/API/Classes/SASInterstitialManager.html#/c:objc(cs)SASInterstitialManager(im)initWithBiddingAdResponse:) of the [`SASInterstitialManager`](https://help-display-sdk.equativ.com/ios/API/Classes/SASInterstitialManager.html) class using the received [`SASBiddingAdResponse`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingAdResponse.html) instance as parameter.

You __can not__ call the `loadAd` method more than once with the same [`SASBiddingAdResponse`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingAdResponse.html) instance. After the first call, the [`SASBiddingAdResponse`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingAdResponse.html) will be marked as 'consumed' and will not be displayable anymore.

Implementation example:
```swift
// MARK: - Bidding manager delegate

func biddingManager(_ biddingManager: SASBiddingManager, didFailToLoad error: any Error) {
    // Equativ did not return any bidding ad, proceed with your competition process
}

func biddingManager(_ biddingManager: SASBiddingManager, didLoadWith biddingAdResponse: SASBiddingAdResponse) {
    // Retrieve the bidding ad price
    let biddingAdPrice = biddingAdResponse.price

    // Perform the bidding competition using biddingAdPrice.cpm and biddingAdPrice.currency properties.
    // Here, we assume Equativ wins the competition

    // Create a new SASInterstitialManager with the received bidding ad response
    let interstitialManager = SASInterstitialManager(biddingAdResponse: biddingAdResponse)
    
    // Set interstitial manager delegate
    interstitialManager.delegate = self

    // Load the interstitial. The interstitial's delegate interstitialManager:didLoadWithInfo: method will be called
    // once the interstitial is ready to be shown. You can then call the show() method from there on.
    interstitialManageR.loadAd()
}
```

##### 3. __SASBiddingManager__ instantiation and bidding call

Instantiate your [`SASBiddingManager`](https://help-display-sdk.equativ.com/ios/API/Classes/SASBiddingManager.html) like so:
```swift
// Create the ad placement
let adPlacement = SASAdPlacement(siteId: 123, pageId: 456, formatId: 789) // Replace with your own ad placement

// Create the bidding manager object
let biddingManager = SASBiddingManager(adPlacement: adPlacement, formatType: .interstitial, currency: .EUR)

// Set previously created listener
biddingManager.delegate = self

// Perform the bidding call
biddingManager.loadAd()
```
