# Ad Presentation

# Step 1: Set Callback Event

Mint Mediation SDK triggers multiple events to notify you of non-page ad activities. You will get the status of corresponding ad placement in each ad event callback method.

Take interstitial ad as an example:

Receive the InterstitialAd event:

MintEvents.onInterstitialAvailabilityChangedEvent += InterstitialAdAvailabilityChangedEvent;

MintEvents.onInterstitialShowedEvent += InterstitialAdShowedEvent;

MintEvents.onInterstitialShowFailedEvent += InterstitialAdShowFailedEvent;

MintEvents.onInterstitialClickedEvent += InterstitialAdClickedEvent;

MintEvents.onInterstitialClosedEvent += InterstitialAdClosedEvent;

The widget will notify the listener of all possible events below:

void InterstitialAdAvailabilityChangedEvent(bool available) {
    Debug.Log("unity-script: I got InterstitialAdReadyEvent: "+available);
}

void InterstitialAdShowFailedEvent(string error) {
    Debug.Log("unity-script: I got InterstitialAdShowFailedEvent, code: " +error);
}

void InterstitialAdClickedEvent(string scene) {
    Debug.Log("unity-script: I got InterstitialAdClickedEvent: "+scene);
}

void InterstitialAdShowedEvent(string scene) {
    Debug.Log("unity-script: I got InterstitialAdOpenedEvent: "+scene);
}

void InterstitialAdClosedEvent(string scene) {
    Debug.Log("unity-script: I got InterstitialAdClosedEvent: "+scene);
}

# Step 2: Check whether ad is available

After the ad is loaded successfully, you will be notified through the XxxxAdAvailabilityChangedEvent callback.

Taking the interstitial ad as an example, the InterstitialAdAvailabilityChangedEvent callback will notify you when an ad can be displayed, which will notify you of the availability of ad resources.

void InterstitialAdAvailabilityChangedEvent(bool available) {
  Debug.Log("UnityApp Interstitial OnInterstitialAdAvailabilityChanged"+available);
}

Note: Before the ad presentation, we recommend that you check whether the ad inventory is available for SDK and call the isXxxxReady method of SDK.Take the interstitial ad as an example:

// …
Mint.Agent.isInterstitialReady();
// … 

# Step 3: Present Ad

After you check that the ad is available, you can call the showXxxx() method to present the ad.Take the interstitial ad as an example:

// …
IfMint.Agent.isInterstitialReady(){
    Mint.Agent.showInterstitial();
}
// …