Μετάβαση στην κονσόλα

firebase::admob::rewarded_video

Loads and displays rewarded video ads via AdMob mediation.

Summary

The rewarded_video namespace contains methods to load and display rewarded video ads via the Google Mobile Ads SDK. The underlying SDK objects for rewarded video on Android and iOS are singletons, so there are no objects to represent individual ads here. Instead, methods in the rewarded_video namespace are invoked to initialize, load, and show.

The basic steps for loading and displaying an ad are:

  1. Call Initialize to init the library and mediation adapters.
  2. Call LoadAd to load an ad (some SDKs may have cached an ad at init time).
  3. Call Show to show the ad to the user.
  4. Repeat steps 2 and 3 as desired.
  5. Call Destroy when your app is completely finished showing rewarded video ads.

Note that Initialize must be the very first thing called, and Destroy must be the very last.

The library maintains a presentation state that indicates whether or not an ad is currently onscreen, but otherwise provides information about its current state through Futures. Initialize, LoadAd, and so on each have a corresponding Future from which apps can determine the result of the previous call.

In addition, applications can create their own subclasses of Listener, pass an instance to the SetListener method, and receive callbacks whenever the presentation state changes or an ad has been viewed in full and the user is due a reward.

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

firebase::admob::rewarded_video::Initialize();

Then, later:

if (firebase::admob::rewarded_video::InitializeLastResult().status() ==
    firebase::kFutureStatusComplete &&
    firebase::admob::rewarded_video::InitializeLastResult().error() ==
    firebase::admob::kAdMobErrorNone) {
  firebase::admob::rewarded_video::LoadAd(my_ad_unit_str, my_ad_request);
}

And after that:

if (firebase::admob::rewarded_video::LoadAdLastResult().status() ==
    firebase::kFutureStatusComplete &&
    firebase::admob::rewarded_video::LoadAdLastResult().error() ==
    firebase::admob::kAdMobErrorNone) {
  firebase::admob::rewarded_video::Show(my_ad_parent);
}

Enumerations

PresentationState{
  kPresentationStateHidden = 0,
  kPresentationStateCoveringUI,
  kPresentationStateVideoHasStarted,
  kPresentationStateVideoHasCompleted
}
enum
The possible presentation states for rewarded video.

Functions

Destroy()
void
Cleans up and deallocates any resources used by rewarded video.
Initialize()
Future< void >
Initializes rewarded video.
InitializeLastResult()
Future< void >
Returns a Future that has the status of the last call to Initialize.
LoadAd(const char *ad_unit_id, const AdRequest & request)
Future< void >
Begins an asynchronous request for an ad.
LoadAdLastResult()
Future< void >
Returns a Future containing the status of the last call to LoadAd.
Pause()
Future< void >
Pauses any background processing associated with rewarded video.
PauseLastResult()
Future< void >
Returns a Future containing the status of the last call to Pause.
Resume()
Future< void >
Resumes the rewarded video system after pausing.
ResumeLastResult()
Future< void >
Returns a Future containing the status of the last call to Resume.
SetListener(Listener *listener)
void
Sets the Listener that should receive callbacks.
Show(AdParent parent)
Future< void >
Shows an ad, assuming one has loaded.
ShowLastResult()
Future< void >
Returns a Future containing the status of the last call to Show.
presentation_state()
Returns the current presentation state, indicating if an ad is visible or if a video has started playing.

Classes

firebase::admob::rewarded_video::Listener

A listener class that developers can extend and pass to SetListener to be notified of rewards and ch