firebase::gma
API for Google Mobile Ads with Firebase.
Summary
The GMA API allows you to load and display mobile ads using the Google Mobile Ads SDK. Each ad format has its own header file.
Deprecated. The Google Mobile Ads (GMA) C++ SDK is deprecated as of June 17, 2024 and should not be adopted in projects that don't already use it. It will enter End-of-Maintenance (EoM) on June 17, 2025. Note that versions of the SDK released before the EoM date will continue to function, but no further bug fixes or changes will be released after the EoM date.
Instead of the Google Mobile Ads C++ SDK, consider using the iOS and Android SDKs from AdMob. For support, reach out to the Google Mobile Ads SDK Technical Forum.
Typedefs |
|
---|---|
AdParent
|
typedefvoid *
This is a platform specific datatype that is required to create a Google Mobile Ads ad. |
Functions |
|
---|---|
DisableMediationInitialization()
|
void
Disables mediation adapter initialization on iOS during initialization of the GMA SDK.
|
DisableSDKCrashReporting()
|
void
Disables automated SDK crash reporting on iOS.
|
GetInitializationStatus()
|
Get the current adapter initialization status.
|
GetRequestConfiguration()
|
Gets the global RequestConfiguration.
|
Initialize(const ::firebase::App & app, InitResult *init_result_out)
|
Deprecated.
The Google Mobile Ads C++ SDK is now deprecated. Please see the SDK reference documentation for more information. Initializes Google Mobile Ads (GMA) via Firebase. |
Initialize(JNIEnv *jni_env, jobject activity, InitResult *init_result_out)
|
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. Initializes Google Mobile Ads (GMA) without Firebase for Android. |
Initialize(InitResult *init_result_out)
|
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. Initializes Google Mobile Ads (GMA) without Firebase for iOS. |
InitializeLastResult()
|
Get the Future returned by a previous call to firebase::gma::Initialize().
|
OpenAdInspector(AdParent parent, AdInspectorClosedListener *listener)
|
void
Opens the ad inspector UI.
|
SetIsSameAppKeyEnabled(bool is_enabled)
|
void
Controls whether the Google Mobile Ads SDK Same App Key is enabled.
|
SetRequestConfiguration(const RequestConfiguration & request_configuration)
|
void
Sets the global RequestConfiguration that will be used for every AdRequest during the app's session.
|
Terminate()
|
void
Terminate GMA.
|
Classes |
|
---|---|
firebase:: |
Information about why an ad operation failed. |
firebase:: |
Listener to be invoked when the Ad Inspector has been closed. |
firebase:: |
A listener for receiving notifications during the lifecycle of a BannerAd. |
firebase:: |
Contains targeting information used to fetch an ad. |
firebase:: |
Information about the result of an ad operation. |
firebase:: |
Describes a reward credited to a user for interacting with a RewardedAd. |
firebase:: |
The size of a banner ad. |
firebase:: |
The monetary value earned from an ad. |
firebase:: |
Loads and displays Google Mobile Ads AdView ads. |
firebase:: |
A listener class that developers can extend and pass to an AdView object's AdView::SetBoundingBoxListener method to be notified of changes to the size of the Ad's bounding box. |
firebase:: |
An immutable snapshot of the GMA SDK’s initialization status, categorized by mediation adapter. |
firebase:: |
Response information for an individual ad network contained within a ResponseInfo object. |
firebase:: |
A snapshot of a mediation adapter's initialization status. |
firebase:: |
Listener to be invoked when ads show and dismiss full screen content, such as a fullscreen ad experience or an in-app browser. |
firebase:: |
Loads and displays Google Mobile Ads interstitial ads. |
firebase:: |
Listener to be invoked when ads have been estimated to earn money. |
firebase:: |
Information about an ad response. |
firebase:: |
Loads and displays Google Mobile Ads rewarded ads. |
firebase:: |
Listener to be invoked when the user earned a reward. |
Structs |
|
---|---|
firebase:: |
The screen location and dimensions of an AdView once it has been initialized. |
firebase:: |
Global configuration that will be used for every AdRequest. |
Namespaces |
|
---|---|
firebase:: |
API for User Messaging Platform. |
Enumerations
AdErrorCode
AdErrorCode
Error codes returned by Future::error().
Properties | |
---|---|
kAdErrorCodeAdAlreadyUsed
|
Will not send request because the ad object has already been used. |
kAdErrorCodeAdNetworkClassLoadError
|
An attempt to load an Ad Network extras class for an ad request has failed. |
kAdErrorCodeAdNotReady
|
The ad is not ready to be shown. |
kAdErrorCodeAdTooLarge
|
Ad is too large for the scene. |
kAdErrorCodeAlreadyInitialized
|
The ad is already initialized (repeat call). |
kAdErrorCodeAppNotInForeground
|
The ad can not be shown when app is not in the foreground. |
kAdErrorCodeApplicationIdentifierMissing
|
Will not send request because the application identifier is missing. |
kAdErrorCodeImageUrlMalformed
|
Error processing image url. |
kAdErrorCodeInsepctorAlreadyOpen
|
The request to show the Ad Inspector failed because it's already open. |
kAdErrorCodeInspectorFailedToLoad
|
An attempt to load the Ad Inspector failed. |
kAdErrorCodeInternalError
|
A call to load an ad has failed due to an internal SDK error. |
kAdErrorCodeInterstitialAlreadyUsed
|
Will not send request because the interstitial object has already been used. |
kAdErrorCodeInvalidAdString
|
Android Ad String is invalid. |
kAdErrorCodeInvalidArgument
|
Invalid argument error. |
kAdErrorCodeInvalidRequest
|
A call to load an ad has failed due to an invalid request. |
kAdErrorCodeLoadInProgress
|
A call has failed because an ad is currently loading. |
kAdErrorCodeMediationAdapterError
|
Error finding or creating a mediation ad network adapter. |
kAdErrorCodeMediationDataError
|
The mediation response was invalid. |
kAdErrorCodeMediationInvalidAdSize
|
Attempting to pass an invalid ad size to an adapter. |
kAdErrorCodeMediationNoFill
|
A mediation ad network adapter received an ad request, but did not fill. The adapter’s error is included as an underlyingError. |
kAdErrorCodeMediationShowError
|
A mediation adapter failed to show the ad. |
kAdErrorCodeNetworkError
|
A call to load an ad has failed due to a network error. |
kAdErrorCodeNoFill
|
A call to load an ad has failed because no ad was available to serve. |
kAdErrorCodeNoWindowToken
|
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). |
kAdErrorCodeNone
|
Call completed successfully. |
kAdErrorCodeNotInTestMode
|
A debug operation failed because the device is not in test mode. |
kAdErrorCodeNotMainThread
|
Attempted to present ad from a non-main thread. This is an internal error which should be reported to support if encountered. |
kAdErrorCodeOSVersionTooLow
|
The current device’s OS is below the minimum required version. |
kAdErrorCodeReceivedInvalidResponse
|
Received invalid response. |
kAdErrorCodeRewardedAdAlreadyUsed
|
Will not send a request because the rewarded ad object has already been used. |
kAdErrorCodeServerError
|
The ad server experienced a failure processing the request. |
kAdErrorCodeTimeout
|
The request was unable to be loaded before being timed out. |
kAdErrorCodeUninitialized
|
The ad has not been fully initialized. |
kAdErrorCodeUnknown
|
Fallback error for any unidentified cases. |
Typedefs
AdParent
void * AdParent
This is a platform specific datatype that is required to create a Google Mobile Ads 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.
Functions
DisableMediationInitialization
void DisableMediationInitialization()
Disables mediation adapter initialization on iOS during initialization of the GMA SDK.
Calling this method may negatively impact your ad performance and should only be called if you will not use GMA SDK controlled mediation during this app session. This method must be called before initializing the GMA SDK or loading ads and has no effect once the SDK has been initialized.
This method has no effect on Android.
DisableSDKCrashReporting
void DisableSDKCrashReporting()
Disables automated SDK crash reporting on iOS.
If not called, the SDK records the original exception handler if available and registers a new exception handler. The new exception handler only reports SDK related exceptions and calls the recorded original exception handler.
This method has no effect on Android.
GetInitializationStatus
AdapterInitializationStatus GetInitializationStatus()
Get the current adapter initialization status.
You can poll this method to check which adapters have been initialized.
GetRequestConfiguration
RequestConfiguration GetRequestConfiguration()
Gets the global RequestConfiguration.
Details | |
---|---|
Returns |
the currently active RequestConfiguration that's being used for every ad request.
|
Initialize
Future< AdapterInitializationStatus > Initialize( const ::firebase::App & app, InitResult *init_result_out )
Initializes Google Mobile Ads (GMA) via Firebase.
Deprecated. The Google Mobile Ads C++ SDK is now deprecated. Please see the SDK reference documentation for more information.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
Initialize
Future< AdapterInitializationStatus > Initialize( JNIEnv *jni_env, jobject activity, InitResult *init_result_out )
Initializes Google Mobile Ads (GMA) without Firebase for Android.
The arguments to Initialize are platform-specific so the caller must do something like this:
#if defined(__ANDROID__) firebase::gma::Initialize(jni_env, activity); #else firebase::gma::Initialize(); #endif
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.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Returns |
Initialize
Future< AdapterInitializationStatus > Initialize( InitResult *init_result_out )
Initializes Google Mobile Ads (GMA) without Firebase for iOS.
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.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
InitializeLastResult
Future< AdapterInitializationStatus > InitializeLastResult()
Get the Future returned by a previous call to firebase::gma::Initialize().
OpenAdInspector
void OpenAdInspector( AdParent parent, AdInspectorClosedListener *listener )
Opens the ad inspector UI.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
SetIsSameAppKeyEnabled
void SetIsSameAppKeyEnabled( bool is_enabled )
Controls whether the Google Mobile Ads SDK Same App Key is enabled.
This function must be invoked after GMA has been initialized. The value set persists across app sessions. The key is enabled by default.
This operation is supported on iOS only. This is a no-op on Android systems.
Details | |||
---|---|---|---|
Parameters |
|
SetRequestConfiguration
void SetRequestConfiguration( const RequestConfiguration & request_configuration )
Sets the global RequestConfiguration that will be used for every AdRequest during the app's session.
Details | |||
---|---|---|---|
Parameters |
|
Terminate
void Terminate()
Terminate GMA.
Frees resources associated with GMA that were allocated during firebase::gma::Initialize().