firebase::gma::RewardedAd

#include <rewarded_ad.h>

Loads and displays Google Mobile Ads rewarded ads.

Summary

RewardedAd is a single-use object that can load and show a single GMA rewarded ad.

RewardedAd objects 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.

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

namespace gma = ::firebase::gma;
gma::RewardedAd* rewarded = new gma::RewardedAd();
rewarded->Initialize(ad_parent);

Then, later:

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

And after that:

if (rewarded->LoadAdLastResult().status() ==
    ::firebase::kFutureStatusComplete &&
    rewarded->LoadAdLastResult().error() ==
    firebase::gma::kAdErrorCodeNone)) {
  rewarded->Show(&my_user_earned_reward_listener);
}

Constructors and Destructors

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

Public functions

Initialize(AdParent parent)
Future< void >
Initialize the RewardedAd object.
InitializeLastResult() const
Future< void >
Returns a Future containing the status of the last call to Initialize.
LoadAd(const char *ad_unit_id, const AdRequest & request)
Begins an asynchronous request for an ad.
LoadAdLastResult() const
Returns a Future containing the status of the last call to LoadAd.
SetFullScreenContentListener(FullScreenContentListener *listener)
void
SetPaidEventListener(PaidEventListener *listener)
void
Registers a callback to be invoked when this ad is estimated to have earned money.
SetServerSideVerificationOptions(const ServerSideVerificationOptions & serverSideVerificationOptions)
void
Sets the server side verification options.
Show(UserEarnedRewardListener *listener)
Future< void >
Shows the RewardedAd.
ShowLastResult() const
Future< void >
Returns a Future containing the status of the last call to Show.

Structs

firebase::gma::RewardedAd::ServerSideVerificationOptions

Options for RewardedAd server-side verification callbacks.

Public functions

Initialize

Future< void > Initialize(
  AdParent parent
)

Initialize the RewardedAd object.

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

InitializeLastResult

Future< void > InitializeLastResult() const 

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

LoadAd

Future< AdResult > LoadAd(
  const char *ad_unit_id,
  const AdRequest & request
)

Begins an asynchronous request for an ad.

Details
Parameters
ad_unit_id
The ad unit ID to use in loading the ad.
request
An AdRequest struct with information about the request to be made (such as targeting info).

LoadAdLastResult

Future< AdResult > LoadAdLastResult() const 

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

RewardedAd

 RewardedAd()

Creates an uninitialized RewardedAd object.

Initialize must be called before the object is used.

SetFullScreenContentListener

void SetFullScreenContentListener(
  FullScreenContentListener *listener
)

Sets the FullScreenContentListener for this RewardedAd.

Details
Parameters
listener
A valid FullScreenContentListener to receive callbacks.

SetPaidEventListener

void SetPaidEventListener(
  PaidEventListener *listener
)

Registers a callback to be invoked when this ad is estimated to have earned money.

Details
Parameters
listener
A valid PaidEventListener to receive callbacks.

SetServerSideVerificationOptions

void SetServerSideVerificationOptions(
  const ServerSideVerificationOptions & serverSideVerificationOptions
)

Sets the server side verification options.

Details
Parameters
serverSideVerificationOptions
A ServerSideVerificationOptions object containing custom data and a user Id.

Show

Future< void > Show(
  UserEarnedRewardListener *listener
)

Shows the RewardedAd.

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

Details
Parameters
listener
The UserEarnedRewardListener to be notified when user earns a reward.

ShowLastResult

Future< void > ShowLastResult() const 

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

~RewardedAd

 ~RewardedAd()