firebase::admob::NativeExpressAdView

#include <native_express_ad_view.h>

Loads and displays ads from AdMob Native Ads Express.

Summary

Each NativeExpressAdView object corresponds to a single AdMob Native Express ad placement. There are methods to load an ad, move it, show it and hide it, and retrieve the bounds of the ad onscreen.

NativeExpressAdView objects maintain a presentation state that indicates whether or not they're currently onscreen, as well as a set of bounds (stored in a BoundingBox struct), but otherwise 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 MoveTo share a single result Future, since they're essentially the same action.

In addition, applications can create their own subclasses of NativeExpressAdView::Listener, pass an instance to the SetListener method, and receive callbacks whenever the presentation state or bounding box of the ad changes.

For example, you could initialize, load, and show a native express ad view while checking the result of the previous action at each step as follows:

namespace admob = ::firebase::admob;
admob::NativeExpressAdView* ad_view = new admob::NativeExpressAdView();
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::admob::kAdMobErrorNone) {
  ad_view->LoadAd(your_ad_request);
}

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Constructors and Destructors

NativeExpressAdView()
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Creates an uninitialized NativeExpressAdView object.
~NativeExpressAdView()
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Public types

Position{
  kPositionTop = 0,
  kPositionBottom,
  kPositionTopLeft,
  kPositionTopRight,
  kPositionBottomLeft,
  kPositionBottomRight
}
enum
The possible screen positions for a NativeExpressAdView.
PresentationState{
  kPresentationStateHidden = 0,
  kPresentationStateVisibleWithoutAd,
  kPresentationStateVisibleWithAd,
  kPresentationStateOpenedPartialOverlay,
  kPresentationStateCoveringUI
}
enum
The presentation state of a NativeExpressAdView.

Public functions

Destroy()
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Cleans up and deallocates any resources used by the NativeExpressAdView.
DestroyLastResult() const
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Returns a Future containing the status of the last call to Destroy.
GetBoundingBox() const Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Retrieves the NativeExpressAdView's current onscreen size and location.
GetPresentationState() const Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Returns the current presentation state of the NativeExpressAdView.
Hide()
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
HideLastResult() const
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Returns a Future containing the status of the last call to Hide.
Initialize(AdParent parent, const char *ad_unit_id, AdSize size)
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Initializes the NativeExpressAdView object.
InitializeLastResult() const
Future< void >
Returns a Future that has the status of the last call to Initialize.
LoadAd(const AdRequest & request)
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Begins an asynchronous request for an ad.
LoadAdLastResult() const
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Returns a Future containing the status of the last call to LoadAd.
MoveTo(int x, int y)
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Moves the NativeExpressAdView so that its top-left corner is located at (x, y).
MoveTo(Position position)
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Moves the NativeExpressAdView so that it's located at the given pre-defined position.
MoveToLastResult() const
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Returns a Future containing the status of the last call to either version of MoveTo.
Pause()
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Pauses the NativeExpressAdView.
PauseLastResult() const
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Returns a Future containing the status of the last call to Pause.
Resume()
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Resumes the NativeExpressAdView after pausing.
ResumeLastResult() const
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Returns a Future containing the status of the last call to Resume.
SetListener(Listener *listener)
void
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Sets the Listener for this object.
Show()
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
ShowLastResult() const
Future< void >
Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.
Returns a Future containing the status of the last call to Show.

Classes

firebase::admob::NativeExpressAdView::Listener

A listener class that developers can extend and pass to a NativeExpressAdView object's SetListener method to be notified of changes to the presentation state and bounding box.

Public types

Position

 Position

The possible screen positions for a NativeExpressAdView.

Properties
kPositionBottom

Bottom of the screen, horizontally centered.

kPositionBottomLeft

Bottom-left corner of the screen.

kPositionBottomRight

Bottom-right corner of the screen.

kPositionTop

Top of the screen, horizontally centered.

kPositionTopLeft

Top-left corner of the screen.

kPositionTopRight

Top-right corner of the screen.

PresentationState

 PresentationState

The presentation state of a NativeExpressAdView.

Properties
kPresentationStateCoveringUI

NativeExpressAdView is completely covering the screen or has caused focus to leave the application (for example, when opening an external browser during a clickthrough).

kPresentationStateHidden

NativeExpressAdView is currently hidden.

kPresentationStateOpenedPartialOverlay

NativeExpressAdView is visible and has opened a partial overlay on the screen.

kPresentationStateVisibleWithAd

NativeExpressAdView is visible and contains an ad.

kPresentationStateVisibleWithoutAd

NativeExpressAdView is visible, but does not contain an ad.

Public functions

Destroy

Future< void > Destroy()

Cleans up and deallocates any resources used by the NativeExpressAdView.

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

DestroyLastResult

Future< void > DestroyLastResult() const 

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

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

GetBoundingBox

BoundingBox GetBoundingBox() const 

Retrieves the NativeExpressAdView's current onscreen size and location.

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Details
Returns
The current size and location. Values are in pixels, and location coordinates originate from the top-left corner of the screen.

GetPresentationState

PresentationState GetPresentationState() const 

Returns the current presentation state of the NativeExpressAdView.

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Details
Returns
The current presentation state.

Hide

Future< void > Hide()

Hides the NativeExpressAdView.

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

HideLastResult

Future< void > HideLastResult() const 

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

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Initialize

Future< void > Initialize(
  AdParent parent,
  const char *ad_unit_id,
  AdSize size
)

Initializes the NativeExpressAdView object.

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Details
Parameters
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 native express ad.

InitializeLastResult

Future< void > InitializeLastResult() const 

Returns a Future that has the status of the last call to Initialize.

LoadAd

Future< void > LoadAd(
  const AdRequest & request
)

Begins an asynchronous request for an ad.

If successful, the ad will automatically be displayed in the NativeExpressAdView. Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Details
Parameters
request
An AdRequest struct with information about the request to be made (such as targeting info).

LoadAdLastResult

Future< void > LoadAdLastResult() const 

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

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

MoveTo

Future< void > MoveTo(
  int x,
  int y
)

Moves the NativeExpressAdView 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 MoveTo would result in an overlap, the NativeExpressAdView is placed just below the status bar, so no overlap occurs. Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Details
Parameters
x
The desired horizontal coordinate.
y
The desired vertical coordinate.

MoveTo

Future< void > MoveTo(
  Position position
)

Moves the NativeExpressAdView so that it's located at the given pre-defined position.

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Details
Parameters
position
The pre-defined position to which to move the NativeExpressAdView.

MoveToLastResult

Future< void > MoveToLastResult() const 

Returns a Future containing the status of the last call to either version of MoveTo.

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

NativeExpressAdView

 NativeExpressAdView()

Creates an uninitialized NativeExpressAdView object.

Initialize must be called before the object is used.

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Pause

Future< void > Pause()

Pauses the NativeExpressAdView.

Should be called whenever the C++ engine pauses or the application loses focus.

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

PauseLastResult

Future< void > PauseLastResult() const 

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

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Resume

Future< void > Resume()

Resumes the NativeExpressAdView after pausing.

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

ResumeLastResult

Future< void > ResumeLastResult() const 

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

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

SetListener

void SetListener(
  Listener *listener
)

Sets the Listener for this object.

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Details
Parameters
listener
A valid NativeExpressAdView::Listener to receive callbacks.

Show

Future< void > Show()

Shows the NativeExpressAdView.

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

ShowLastResult

Future< void > ShowLastResult() const 

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

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

~NativeExpressAdView

 ~NativeExpressAdView()

Deprecated. This class will be removed in a future version. Native Express Ads has been discontinued, and are no longer served.

Send feedback about...

Need help? Visit our support page.