firebase:: gma:: AdView
#include <ad_view.h>
Loads and displays Google Mobile Ads AdView ads.
Summary
Each AdView object corresponds to a single GMA ad placement of a specified size. There are methods to load an ad, move it, show it and hide it, and retrieve the bounds of the ad onscreen.
AdView objects provide information about their current state through Futures. Methods like Initialize, LoadAd, and Hide each have a corresponding Future from which the result of the last call can be determined. The two variants of SetPosition share a single result Future, since they're essentially the same action.
For example, you could initialize, load, and show an AdView while checking the result of the previous action at each step as follows:
namespace gma = ::firebase::gma; gma::AdView* ad_view = new gma::AdView(); ad_view->Initialize(ad_parent, "YOUR_AD_UNIT_ID", desired_ad_size)
Then, later:
if (ad_view->InitializeLastResult().status() == ::firebase::kFutureStatusComplete && ad_view->InitializeLastResult().error() == firebase::gma::kAdErrorCodeNone) { ad_view->LoadAd(your_ad_request); }
Deprecated. The Google Mobile Ads C++ SDK is now deprecated. Please see https://developers.google.com/admob/cpp/reference/namespace/firebase/gma for more information.
Constructors and Destructors |
|
---|---|
AdView()
Creates an uninitialized AdView object.
|
|
~AdView()
|
Public types |
|
---|---|
Position{
|
enum The possible screen positions for a AdView, configured via SetPosition. |
Protected attributes |
|
---|---|
ad_listener_
|
Pointer to a listener for AdListener events.
|
ad_view_bounding_box_listener_
|
Pointer to a listener for BoundingBox events.
|
paid_event_listener_
|
Pointer to a listener for paid events.
|
Public functions |
|
---|---|
Destroy()
|
Future< void >
Cleans up and deallocates any resources used by the AdView.
|
DestroyLastResult() const
|
Future< void >
|
Hide()
|
Future< void >
Hides the AdView.
|
HideLastResult() const
|
Future< void >
|
Initialize(AdParent parent, const char *ad_unit_id, const AdSize & size)
|
Future< void >
Initializes the AdView object.
|
InitializeLastResult() const
|
Future< void >
Returns a Future that has the status of the last call to Initialize.
|
LoadAd(const AdRequest & request)
|
Begins an asynchronous request for an ad.
|
LoadAdLastResult() const
|
|
Pause()
|
Future< void >
Pauses the AdView.
|
PauseLastResult() const
|
Future< void >
|
Resume()
|
Future< void >
Resumes the AdView after pausing.
|
ResumeLastResult() const
|
Future< void >
|
SetAdListener(AdListener *listener)
|
void
Sets an AdListener for this ad view.
|
SetBoundingBoxListener(AdViewBoundingBoxListener *listener)
|
void
Sets a listener to be invoked when the Ad's bounding box changes size or location.
|
SetPaidEventListener(PaidEventListener *listener)
|
void
Sets a listener to be invoked when this ad is estimated to have earned money.
|
SetPosition(int x, int y)
|
Future< void >
Moves the AdView so that its top-left corner is located at (x, y).
|
SetPosition(Position position)
|
Future< void >
Moves the AdView so that it's located at the given predefined position.
|
SetPositionLastResult() const
|
Future< void >
Returns a Future containing the status of the last call to either version of SetPosition.
|
Show()
|
Future< void >
Shows the AdView.
|
ShowLastResult() const
|
Future< void >
|
ad_size() const
|
|
bounding_box() const
|
Retrieves the AdView's current onscreen size and location.
|
Public types
Position
Position
The possible screen positions for a AdView, configured via SetPosition.
Protected attributes
ad_view_bounding_box_listener_
AdViewBoundingBoxListener * ad_view_bounding_box_listener_
Pointer to a listener for BoundingBox events.
paid_event_listener_
PaidEventListener * paid_event_listener_
Pointer to a listener for paid events.
Public functions
AdView
AdView()
Creates an uninitialized AdView object.
Initialize must be called before the object is used.
Destroy
Future< void > Destroy()
Cleans up and deallocates any resources used by the AdView.
You must call this asynchronous operation before this object's destructor is invoked or risk leaking device resources.
DestroyLastResult
Future< void > DestroyLastResult() const
HideLastResult
Future< void > HideLastResult() const
Initialize
Future< void > Initialize( AdParent parent, const char *ad_unit_id, const AdSize & size )
Initializes the AdView object.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
InitializeLastResult
Future< void > InitializeLastResult() const
Returns a Future that has the status of the last call to Initialize.
Pause
Future< void > Pause()
Pauses the AdView.
Should be called whenever the C++ engine pauses or the application loses focus.
PauseLastResult
Future< void > PauseLastResult() const
ResumeLastResult
Future< void > ResumeLastResult() const
SetAdListener
void SetAdListener( AdListener *listener )
Sets an AdListener for this ad view.
Details | |||
---|---|---|---|
Parameters |
|
SetBoundingBoxListener
void SetBoundingBoxListener( AdViewBoundingBoxListener *listener )
Sets a listener to be invoked when the Ad's bounding box changes size or location.
Details | |||
---|---|---|---|
Parameters |
|
SetPaidEventListener
void SetPaidEventListener( PaidEventListener *listener )
Sets a listener to be invoked when this ad is estimated to have earned money.
Details | |||
---|---|---|---|
Parameters |
|
SetPosition
Future< void > SetPosition( int x, int y )
Moves the AdView so that its top-left corner is located at (x, y).
Coordinates are in pixels from the top-left corner of the screen.
When built for Android, the library will not display an ad on top of or beneath an Activity
's status bar. If a call to SetPosition would result in an overlap, the AdView is placed just below the status bar, so no overlap occurs.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
a Future which will be completed when this move operation completes.
|
SetPositionLastResult
Future< void > SetPositionLastResult() const
Returns a Future containing the status of the last call to either version of SetPosition.
ShowLastResult
Future< void > ShowLastResult() const
ad_size
AdSize ad_size() const
bounding_box
BoundingBox bounding_box() const
Retrieves the AdView's current onscreen size and location.
Details | |
---|---|
Returns |
The current size and location. Values are in pixels, and location coordinates originate from the top-left corner of the screen.
|
~AdView
~AdView()