# firebase::gma::InterstitialAd


`#include <interstitial_ad.h>`

Loads and displays Google Mobile Ads interstitial ads.

## Summary

[InterstitialAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad) is a single-use object that can load and show a single GMA interstitial ad.

[InterstitialAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad) objects provide information about their current state through Futures. [Initialize](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a7e2facde6a75a5a0a448c6e0662075c4), [LoadAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a7b4ee29b4e5832a26c97df56e2e86a8b), and [Show](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a12d23438562c10b21e7eb2f86f4ef218) each have a corresponding [Future](https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future) from which you can determine result of the previous call.

Here's how one might initialize, load, and show an interstitial ad while checking against the result of the previous action at each step:


```c++
namespace gma = ::firebase::gma;
gma::InterstitialAd* interstitial = new gma::InterstitialAd();
interstitial->Initialize(ad_parent);
```

<br />

Then, later:


```c++
if (interstitial->InitializeLastResult().status() ==
    ::firebase::kFutureStatusComplete &&
    interstitial->InitializeLastResult().error() ==
    firebase::gma::kAdErrorCodeNone) {
  interstitial->LoadAd( "YOUR_AD_UNIT_ID", my_ad_request);
}
```

<br />

And after that:


```c++
if (interstitial->LoadAdLastResult().status() ==
    ::firebase::kFutureStatusComplete &&
    interstitial->LoadAdLastResult().error() ==
    firebase::gma::kAdErrorCodeNone)) {
  interstitial->Show();
}
```

<br />

**[Deprecated.](https://developers.google.com/admob/cpp/reference/deprecated/deprecated)** The Google Mobile Ads C++ SDK is now deprecated. Please see <https://developers.google.com/admob/cpp/reference/namespace/firebase/gma> for more information.

| ### Constructors and Destructors ||
|---|---|
| `https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a62b0bcde05b77dcde7c6a6c7fe5d9478()` Creates an uninitialized [InterstitialAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad) object. ||
| `https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1aee65e0041f23726e03d32064fc9f3941()` ||

| ### Public functions ||
|---|---|
| `https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a7e2facde6a75a5a0a448c6e0662075c4(https://developers.google.com/admob/cpp/reference/namespace/firebase/gma#namespacefirebase_1_1gma_1a1ed4b6a8f045afeb8aea12e47884ca9c parent)` | `https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future< void >` Initialize the [InterstitialAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad) object. |
| `https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a04c2bf11a59a701bc406f6ec59f204c3() const ` | `https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future< void >` Returns a [Future](https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future) containing the status of the last call to [Initialize](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a7e2facde6a75a5a0a448c6e0662075c4). |
| `https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a7b4ee29b4e5832a26c97df56e2e86a8b(const char *ad_unit_id, const https://developers.google.com/admob/cpp/reference/class/firebase/gma/ad-request#classfirebase_1_1gma_1_1_ad_request & request)` | `https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future< https://developers.google.com/admob/cpp/reference/class/firebase/gma/ad-result#classfirebase_1_1gma_1_1_ad_result >` Begins an asynchronous request for an ad. |
| `https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1ad7318fa7469f73a269c37e2d0efe685e() const ` | `https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future< https://developers.google.com/admob/cpp/reference/class/firebase/gma/ad-result#classfirebase_1_1gma_1_1_ad_result >` Returns a [Future](https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future) containing the status of the last call to [LoadAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a7b4ee29b4e5832a26c97df56e2e86a8b). |
| `https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1aecc8414a930c11c44ea93714fecfb72a(https://developers.google.com/admob/cpp/reference/class/firebase/gma/full-screen-content-listener#classfirebase_1_1gma_1_1_full_screen_content_listener *listener)` | `void` Sets the [FullScreenContentListener](https://developers.google.com/admob/cpp/reference/class/firebase/gma/full-screen-content-listener#classfirebase_1_1gma_1_1_full_screen_content_listener) for this [InterstitialAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad). |
| `https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a21f53766610a10c1f61419e0ef77dc40(https://developers.google.com/admob/cpp/reference/class/firebase/gma/paid-event-listener#classfirebase_1_1gma_1_1_paid_event_listener *listener)` | `void` Registers a callback to be invoked when this ad is estimated to have earned money. |
| `https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a12d23438562c10b21e7eb2f86f4ef218()` | `https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future< void >` Shows the [InterstitialAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad). |
| `https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a2e3e59e17ec66f27c20a85aa1a9eea60() const ` | `https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future< void >` Returns a [Future](https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future) containing the status of the last call to [Show](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a12d23438562c10b21e7eb2f86f4ef218). |

## Public functions

### Initialize

```c++
Future< void > Initialize(
  AdParent parent
)
```
Initialize the [InterstitialAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad) object.

<br />

Details Parameters `parent` The platform-specific UI element that will host the ad.

### InitializeLastResult

```c++
Future< void > InitializeLastResult() const 
```
Returns a [Future](https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future) containing the status of the last call to [Initialize](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a7e2facde6a75a5a0a448c6e0662075c4).

### InterstitialAd

```c++
 InterstitialAd()
```
Creates an uninitialized [InterstitialAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad) object.

[Initialize](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a7e2facde6a75a5a0a448c6e0662075c4) must be called before the object is used.

### LoadAd

```c++
Future< AdResult > LoadAd(
  const char *ad_unit_id,
  const AdRequest & request
)
```
Begins an asynchronous request for an ad.

<br />

Details Parameters `ad_unit_id` The ad unit ID to use in loading the ad. `request` An [AdRequest](https://developers.google.com/admob/cpp/reference/class/firebase/gma/ad-request#classfirebase_1_1gma_1_1_ad_request) struct with information about the request to be made (such as targeting info).

### LoadAdLastResult

```c++
Future< AdResult > LoadAdLastResult() const 
```
Returns a [Future](https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future) containing the status of the last call to [LoadAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a7b4ee29b4e5832a26c97df56e2e86a8b).

### SetFullScreenContentListener

```c++
void SetFullScreenContentListener(
  FullScreenContentListener *listener
)
```
Sets the [FullScreenContentListener](https://developers.google.com/admob/cpp/reference/class/firebase/gma/full-screen-content-listener#classfirebase_1_1gma_1_1_full_screen_content_listener) for this [InterstitialAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad).

<br />

Details Parameters `listener` A valid [FullScreenContentListener](https://developers.google.com/admob/cpp/reference/class/firebase/gma/full-screen-content-listener#classfirebase_1_1gma_1_1_full_screen_content_listener) to receive callbacks.

### SetPaidEventListener

```c++
void SetPaidEventListener(
  PaidEventListener *listener
)
```
Registers a callback to be invoked when this ad is estimated to have earned money.

<br />

Details Parameters `listener` A valid [PaidEventListener](https://developers.google.com/admob/cpp/reference/class/firebase/gma/paid-event-listener#classfirebase_1_1gma_1_1_paid_event_listener) to receive callbacks.

### Show

```c++
Future< void > Show()
```
Shows the [InterstitialAd](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad).

This should not be called unless an ad has already been loaded.

### ShowLastResult

```c++
Future< void > ShowLastResult() const 
```
Returns a [Future](https://developers.google.com/admob/cpp/reference/class/firebase/future#classfirebase_1_1_future) containing the status of the last call to [Show](https://developers.google.com/admob/cpp/reference/class/firebase/gma/interstitial-ad#classfirebase_1_1gma_1_1_interstitial_ad_1a12d23438562c10b21e7eb2f86f4ef218).

### \~InterstitialAd

```c++
 ~InterstitialAd()
```