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{
|
enum The presentation states of an InterstitialAd. |
Public functions |
|
|---|---|
GetPresentationState() const
|
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 >
|
SetListener(Listener *listener)
|
void
Sets the Listener for this InterstitialAd.
|
Show()
|
Future< void >
Shows the InterstitialAd.
|
ShowLastResult() const
|
Future< void >
|
Classes |
|
|---|---|
|
firebase:: |
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
PresentationState GetPresentationState() const
Returns the current presentation state of the InterstitialAd.
| Details | |
|---|---|
| Returns |
The current presentation state.
|
Initialize
Future< void > Initialize( AdParent parent, const char *ad_unit_id )
Initialize the InterstitialAd object.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
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::GetPresentationState method can be used to track the progress of the request.
| Details | |||
|---|---|---|---|
| Parameters |
|
LoadAdLastResult
Future< void > LoadAdLastResult() const
SetListener
void SetListener( Listener *listener )
Sets the Listener for this InterstitialAd.
| Details | |||
|---|---|---|---|
| Parameters |
|
Show
Future< void > Show()
Shows the InterstitialAd.
This should not be called unless an ad has already been loaded.
ShowLastResult
Future< void > ShowLastResult() const
~InterstitialAd
~InterstitialAd()

