firebase::admob

API for AdMob with Firebase.

Summary

The AdMob API allows you to load and display mobile ads using the Google Mobile Ads SDK. Each ad format has its own header file.

Enumerations

AdMobError{
  kAdMobErrorNone,
  kAdMobErrorUninitialized,
  kAdMobErrorAlreadyInitialized,
  kAdMobErrorLoadInProgress,
  kAdMobErrorInternalError,
  kAdMobErrorInvalidRequest,
  kAdMobErrorNetworkError,
  kAdMobErrorNoFill,
  kAdMobErrorNoWindowToken
}
enum
Error codes returned by Future::Error().
AdSizeType enum
Types of ad sizes.
ChildDirectedTreatmentState{
  kChildDirectedTreatmentStateUnknown = 0,
  kChildDirectedTreatmentStateTagged,
  kChildDirectedTreatmentStateNotTagged
}
enum
Indicates whether an ad request is considered tagged for child-directed treatment.
Gender{
  kGenderUnknown = 0,
  kGenderMale,
  kGenderFemale
}
enum
Gender information used as part of the firebase::admob::AdRequest struct.

Typedefs

AdParent typedef
void *
This is a platform specific datatype that is required to create an AdMob ad.

Functions

Initialize(const ::firebase::App & app)
Initializes AdMob via Firebase.
Initialize(const ::firebase::App & app, const char *admob_app_id)
Initializes AdMob via Firebase with the publisher's AdMob app ID.
Initialize(JNIEnv *jni_env, jobject activity)
Initializes AdMob without Firebase for Android.
Initialize(JNIEnv *jni_env, jobject activity, const char *admob_app_id)
Initializes AdMob via Firebase with the publisher's AdMob app ID.
Initialize()
Initializes AdMob without Firebase for iOS.
Initialize(const char *admob_app_id)
Initializes AdMob with the publisher's AdMob app ID and without Firebase for iOS.
Terminate()
void
Terminate AdMob.

Classes

firebase::admob::BannerView

Loads and displays AdMob banner ads.

firebase::admob::InterstitialAd

Loads and displays AdMob interstitial ads.

firebase::admob::NativeExpressAdView

Loads and displays ads from AdMob Native Ads Express.

Structs

firebase::admob::AdRequest

The information needed to request an ad.

firebase::admob::AdSize

An ad size value to be used in requesting ads.

firebase::admob::BoundingBox

The screen location and dimensions of an ad view once it has been initialized.

firebase::admob::KeyValuePair

Generic Key-Value container used for the "extras" values in an firebase::admob::AdRequest.

Namespaces

firebase::admob::internal
firebase::admob::rewarded_video

Loads and displays rewarded video ads via AdMob mediation.

Enumerations

AdMobError

 AdMobError

Error codes returned by Future::Error().

Properties
kAdMobErrorAlreadyInitialized

The ad is already initialized (repeat call).

kAdMobErrorInternalError

A call to load an ad has failed due to an internal SDK error.

kAdMobErrorInvalidRequest

A call to load an ad has failed due to an invalid request.

kAdMobErrorLoadInProgress

A call has failed because an ad is currently loading.

kAdMobErrorNetworkError

A call to load an ad has failed due to a network error.

kAdMobErrorNoFill

A call to load an ad has failed because no ad was available to serve.

kAdMobErrorNoWindowToken

An attempt has been made to show an ad on an Android Activity that has no window token (such as one that's not done initializing).

kAdMobErrorNone

Call completed successfully.

kAdMobErrorUninitialized

The ad has not been fully initialized.

AdSizeType

 AdSizeType

Types of ad sizes.

ChildDirectedTreatmentState

 ChildDirectedTreatmentState

Indicates whether an ad request is considered tagged for child-directed treatment.

Properties
kChildDirectedTreatmentStateNotTagged

The request is not tagged for child-directed treatment.

kChildDirectedTreatmentStateTagged

The request is tagged for child-directed treatment.

kChildDirectedTreatmentStateUnknown

The child-directed status for the request is not indicated.

Gender

 Gender

Gender information used as part of the firebase::admob::AdRequest struct.

Properties
kGenderFemale

The current user is known to be female.

kGenderMale

The current user is known to be male.

kGenderUnknown

The gender of the current user is unknown or unspecified by the publisher.

Typedefs

AdParent

void * AdParent

This is a platform specific datatype that is required to create an AdMob ad.

The following defines the datatype on each platform:

  • Android: A jobject which references an Android Activity.
  • iOS: An id which references an iOS UIView.
A void pointer for stub classes.

Functions

Initialize

InitResult Initialize(
  const ::firebase::App & app
)

Initializes AdMob via Firebase.

Details
Parameters
app
The Firebase app for which to initialize mobile ads.
Returns
kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if Google Play services is not available on the current device and the Google Mobile Ads SDK requires Google Play services (for example, when using 'play-services-ads-lite').

Initialize

InitResult Initialize(
  const ::firebase::App & app,
  const char *admob_app_id
)

Initializes AdMob via Firebase with the publisher's AdMob app ID.

Initializing the Google Mobile Ads SDK with the AdMob app ID at app launch allows the SDK to fetch app-level settings and perform configuration tasks as early as possible. This can help reduce latency for the initial ad request. AdMob app IDs are unique identifiers given to mobile apps when they're registered in the AdMob console. To find your app ID in the AdMob console, click the App management (https://apps.admob.com/#account/appmgmt:) option under the settings dropdown (located in the upper right-hand corner). App IDs have the form ca-app-pub-XXXXXXXXXXXXXXXX~NNNNNNNNNN.

Details
Parameters
app
The Firebase app for which to initialize mobile ads.
admob_app_id
The publisher's AdMob app ID.
Returns
kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if Google Play services is not available on the current device and the Google Mobile Ads SDK requires Google Play services (for example, when using 'play-services-ads-lite').

Initialize

InitResult Initialize(
  JNIEnv *jni_env,
  jobject activity
)

Initializes AdMob without Firebase for Android.

The arguments to Initialize are platform-specific so the caller must do something like this:

#if defined(__ANDROID__)
firebase::admob::Initialize(jni_env, activity);
#else
firebase::admob::Initialize();
#endif

Details
Parameters
jni_env
JNIEnv pointer.
activity
Activity used to start the application.
Returns
kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if Google Play services is not available on the current device and the AdMob SDK requires Google Play services (for example when using 'play-services-ads-lite').

Initialize

InitResult Initialize(
  JNIEnv *jni_env,
  jobject activity,
  const char *admob_app_id
)

Initializes AdMob via Firebase with the publisher's AdMob app ID.

Initializing the Google Mobile Ads SDK with the AdMob app ID at app launch allows the SDK to fetch app-level settings and perform configuration tasks as early as possible. This can help reduce latency for the initial ad request. AdMob app IDs are unique identifiers given to mobile apps when they're registered in the AdMob console. To find your app ID in the AdMob console, click the App management (https://apps.admob.com/#account/appmgmt:) option under the settings dropdown (located in the upper right-hand corner). App IDs have the form ca-app-pub-XXXXXXXXXXXXXXXX~NNNNNNNNNN.

The arguments to Initialize are platform-specific so the caller must do something like this:

#if defined(__ANDROID__)
firebase::admob::Initialize(jni_env, activity, admob_app_id);
#else
firebase::admob::Initialize(admob_app_id);
#endif

Details
Parameters
jni_env
JNIEnv pointer.
activity
Activity used to start the application.
admob_app_id
The publisher's AdMob app ID.
Returns
kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if Google Play services is not available on the current device and the AdMob SDK requires Google Play services (for example when using 'play-services-ads-lite').

Initialize

InitResult Initialize()

Initializes AdMob without Firebase for iOS.

Initialize

InitResult Initialize(
  const char *admob_app_id
)

Initializes AdMob with the publisher's AdMob app ID and without Firebase for iOS.

Initializing the Google Mobile Ads SDK with the AdMob app ID at app launch allows the SDK to fetch app-level settings and perform configuration tasks as early as possible. This can help reduce latency for the initial ad request. AdMob app IDs are unique identifiers given to mobile apps when they're registered in the AdMob console. To find your app ID in the AdMob console, click the App management (https://apps.admob.com/#account/appmgmt:) option under the settings dropdown (located in the upper right-hand corner). App IDs have the form ca-app-pub-XXXXXXXXXXXXXXXX~NNNNNNNNNN.

Details
Parameters
admob_app_id
The publisher's AdMob app ID.
Returns
kInitResultSuccess if initialization succeeded

Terminate

void Terminate()

Terminate AdMob.

Frees resources associated with AdMob that were allocated during firebase::admob::Initialize().

Send feedback about...

Need help? Visit our support page.