firebase::admob::InterstitialAd

#include <interstitial_ad.h>

Loads and displays AdMob interstitial ads.

Summary

InterstitialAd is a single-use object that can load and show a single AdMob interstitial ad.

InterstitialAd objects maintain a presentation state that indicates whether or not they're currently onscreen, but otherwise provide information about their current state through Futures. Initialize, LoadAd, and Show each have a corresponding Future from which you can determine result of the previous call.

In addition, applications can create their own subclasses of InterstitialAd::Listener, pass an instance to the SetListener method, and receive callbacks whenever the presentation state changes.

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

namespace admob = ::firebase::admob;
admob::InterstitialAd* interstitial = new admob::InterstitialAd();
interstitial->Initialize(ad_parent, "YOUR_AD_UNIT_ID")

Then, later:

if (interstitial->InitializeLastResult().status() ==
    ::firebase::kFutureStatusComplete &&
    interstitial->InitializeLastResult().error() ==
    firebase::admob::kAdMobErrorNone) {
  interstitial->LoadAd(my_ad_request);
}

And after that:

if (interstitial->LoadAdLastResult().status() ==
    ::firebase::kFutureStatusComplete &&
    interstitial->LoadAdLastResult().error() ==
    firebase::admob::kAdMobErrorNone)) {
  interstitial->Show();
}

Constructors and Destructors

InterstitialAd()
Creates an uninitialized InterstitialAd object.
~InterstitialAd()

Public types

PresentationState{
  kPresentationStateHidden = 0,
  kPresentationStateCoveringUI
}
enum
The presentation states of an InterstitialAd.

Public functions

GetPresentationState() const
FIREBASE_DEPRECATED PresentationState
Deprecated. Renamed to presentation_state().
Returns the current presentation state of the InterstitialAd.
Initialize(AdParent parent, const char *ad_unit_id)
Future< void >
Initialize the InterstitialAd object.
InitializeLastResult() const
Future< void >
Returns a Future containing the status of the last call to Initialize.
LoadAd(const AdRequest & request)
Future< void >
Begins an asynchronous request for an ad.
LoadAdLastResult() const
Future< void >
Returns a Future containing the status of the last call to LoadAd.
SetListener(Listener *listener)
void
Sets the Listener for this InterstitialAd.
Show()
Future< void >
Shows the InterstitialAd.
ShowLastResult() const
Future< void >
Returns a Future containing the status of the last call to Show.
presentation_state() const
Returns the current presentation state of the InterstitialAd.

Classes

firebase::admob::InterstitialAd::Listener

A listener class that developers can extend and pass to an InterstitialAd object's SetListener method to be notified of presentation state changes.

Public types

PresentationState

 PresentationState

The presentation states of an InterstitialAd.

Properties
kPresentationStateCoveringUI

InterstitialAd is being shown or has caused focus to leave the application (for example, when opening an external browser during a clickthrough).

kPresentationStateHidden

InterstitialAd is not currently being shown.

Public functions

GetPresentationState

FIREBASE_DEPRECATED PresentationState GetPresentationState() const 

Returns the current presentation state of the InterstitialAd.

Deprecated. Renamed to presentation_state().

Details
Returns
The current presentation state.

Initialize

Future< void > Initialize(
  AdParent parent,
  const char *ad_unit_id
)

Initialize the InterstitialAd object.

Details
Parameters
parent
The platform-specific UI element that will host the ad.
ad_unit_id
The ad unit ID to use in loading the ad.

InitializeLastResult

Future< void > InitializeLastResult() const 

Returns a Future containing the status of the last call to Initialize.

InterstitialAd

 InterstitialAd()

Creates an uninitialized InterstitialAd object.

Initialize must be called before the object is used.

LoadAd

Future< void > LoadAd(
  const AdRequest & request
)

Begins an asynchronous request for an ad.

The InterstitialAd::presentation_state method can be used to track the progress of the request.

Details
Parameters
request
An AdRequest struct with information about the request to be made (such as targeting info).

LoadAdLastResult

Future< void > LoadAdLastResult() const 

Returns a Future containing the status of the last call to LoadAd.

SetListener

void SetListener(
  Listener *listener
)

Sets the Listener for this InterstitialAd.

Details
Parameters
listener
A valid InterstititalAd::Listener to receive callbacks.

Show

Future< void > Show()

Shows the InterstitialAd.

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

ShowLastResult

Future< void > ShowLastResult() const 

Returns a Future containing the status of the last call to Show.

presentation_state

PresentationState presentation_state() const 

Returns the current presentation state of the InterstitialAd.

Details
Returns
The current presentation state.

~InterstitialAd

 ~InterstitialAd()

Send feedback about...

Need help? Visit our support page.