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:
- Call Initialize to init the library and mediation adapters.
- Call LoadAd to load an ad (some SDKs may have cached an ad at init time).
- Call Show to show the ad to the user.
- Repeat steps 2 and 3 as desired.
- 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{
|
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 >
|
Pause()
|
Future< void >
Pauses any background processing associated with rewarded video.
|
PauseLastResult()
|
Future< void >
|
Resume()
|
Future< void >
Resumes the rewarded video system after pausing.
|
ResumeLastResult()
|
Future< void >
|
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 >
|
presentation_state()
|
Returns the current presentation state, indicating if an ad is visible or if a video has started playing.
|
Classes |
|
---|---|
firebase:: |
A listener class that developers can extend and pass to SetListener to be notified of rewards and changes to the presentation state. |
firebase:: |
A polling-based listener that developers can instantiate and pass to SetListener in order to queue rewards for later retrieval. |
Structs |
|
---|---|
firebase:: |
A reward to be given to the user in exchange for watching a rewarded video ad. |
Enumerations
PresentationState
PresentationState
The possible presentation states for rewarded video.
Functions
Destroy
void Destroy()
Cleans up and deallocates any resources used by rewarded video.
No other methods in rewarded_video should be called once this method has been invoked. The system is closed for business at that point.
Initialize
Future< void > Initialize()
Initializes rewarded video.
This must be the first method invoked in this namespace.
InitializeLastResult
Future< void > InitializeLastResult()
Returns a Future that has the status of the last call to Initialize.
LoadAd
Future< void > LoadAd( const char *ad_unit_id, const AdRequest & request )
Begins an asynchronous request for an ad.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
LoadAdLastResult
Future< void > LoadAdLastResult()
Pause
Future< void > Pause()
Pauses any background processing associated with rewarded video.
Should be called whenever the C++ engine pauses or the application loses focus.
PauseLastResult
Future< void > PauseLastResult()
ResumeLastResult
Future< void > ResumeLastResult()
SetListener
void SetListener( Listener *listener )
ShowLastResult
Future< void > ShowLastResult()
presentation_state
PresentationState presentation_state()
Returns the current presentation state, indicating if an ad is visible or if a video has started playing.
Details | |
---|---|
Returns |
The current presentation state.
|