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.
Public types
Position
{
kPositionUndefined
= -1,
kPositionTop
= 0,
kPositionBottom
,
kPositionTopLeft
,
kPositionTopRight
,
kPositionBottomLeft
,
kPositionBottomRight
}
Protected attributes
Public functions
DestroyLastResult
() const
HideLastResult
() const
Initialize
( AdParent
parent, const char *ad_unit_id, const AdSize
& size)
InitializeLastResult
() const
Future
< void >
LoadAdLastResult
() const
PauseLastResult
() const
ResumeLastResult
() const
SetAdListener
( AdListener
*listener)
void
SetBoundingBoxListener
( AdViewBoundingBoxListener
*listener)
void
SetPaidEventListener
( PaidEventListener
*listener)
void
SetPosition
(int x, int y)
SetPosition
( Position
position)
SetPositionLastResult
() const
Future
< void >
ShowLastResult
() const
bounding_box
() const
Public types
Position
Position
The possible screen positions for a AdView , configured via SetPosition .
Bottom of the screen, horizontally centered.
Bottom-left corner of the screen.
Bottom-right corner of the screen.
Top of the screen, horizontally centered.
Top-left corner of the screen.
Top-right corner of the screen.
The position isn't one of the predefined screen locations.
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.
parent
|
The platform-specific UI element that will host the ad.
|
ad_unit_id
|
The ad unit ID to use when requesting ads.
|
size
|
The desired ad size for the ad.
|
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 )
SetBoundingBoxListener
void SetBoundingBoxListener ( AdViewBoundingBoxListener * listener )
Sets a listener to be invoked when the Ad's bounding box changes size or location.
listener
SetPaidEventListener
void SetPaidEventListener ( PaidEventListener * listener )
Sets a listener to be invoked when this ad is estimated to have earned money.
listener
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.
x
|
The desired horizontal coordinate.
|
y
|
The desired vertical coordinate.
|
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 ()