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 .
Enumerations
AdErrorCode
{
kAdErrorCodeNone
,
kAdErrorCodeUninitialized
,
kAdErrorCodeAlreadyInitialized
,
kAdErrorCodeLoadInProgress
,
kAdErrorCodeInternalError
,
kAdErrorCodeInvalidRequest
,
kAdErrorCodeNetworkError
,
kAdErrorCodeNoFill
,
kAdErrorCodeNoWindowToken
,
kAdErrorCodeAdNetworkClassLoadError
,
kAdErrorCodeServerError
,
kAdErrorCodeOSVersionTooLow
,
kAdErrorCodeTimeout
,
kAdErrorCodeInterstitialAlreadyUsed
,
kAdErrorCodeMediationDataError
,
kAdErrorCodeMediationAdapterError
,
kAdErrorCodeMediationInvalidAdSize
,
kAdErrorCodeInvalidArgument
,
kAdErrorCodeReceivedInvalidResponse
,
kAdErrorCodeRewardedAdAlreadyUsed
,
kAdErrorCodeMediationNoFill
,
kAdErrorCodeAdAlreadyUsed
,
kAdErrorCodeApplicationIdentifierMissing
,
kAdErrorCodeInvalidAdString
,
kAdErrorCodeAppNotInForeground
,
kAdErrorCodeMediationShowError
,
kAdErrorCodeAdNotReady
,
kAdErrorCodeAdTooLarge
,
kAdErrorCodeNotMainThread
,
kAdErrorCodeNotInTestMode
,
kAdErrorCodeInspectorFailedToLoad
,
kAdErrorCodeInsepctorAlreadyOpen
,
kAdErrorCodeImageUrlMalformed
,
kAdErrorCodeUnknown
}
Typedefs
void *
Functions
void
void
Initialize
(const :: firebase::App
& app, InitResult *init_result_out)
Initialize
(JNIEnv *jni_env, jobject activity, InitResult *init_result_out)
Initialize
(InitResult *init_result_out)
OpenAdInspector
( AdParent
parent, AdInspectorClosedListener
*listener)
void
SetIsSameAppKeyEnabled
(bool is_enabled)
void
SetRequestConfiguration
(const RequestConfiguration
& request_configuration)
void
Terminate
()
void
Classes
Information about why an ad operation failed.
Listener to be invoked when the Ad Inspector has been closed.
A listener for receiving notifications during the lifecycle of a BannerAd.
Contains targeting information used to fetch an ad.
Information about the result of an ad operation.
Describes a reward credited to a user for interacting with a RewardedAd .
The size of a banner ad.
The monetary value earned from an ad.
Loads and displays Google Mobile Ads AdView ads.
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.
An immutable snapshot of the GMA SDK’s initialization status, categorized by mediation adapter.
Response information for an individual ad network contained within a ResponseInfo object.
A snapshot of a mediation adapter's initialization status.
Listener to be invoked when ads show and dismiss full screen content, such as a fullscreen ad experience or an in-app browser.
Loads and displays Google Mobile Ads interstitial ads.
Listener to be invoked when ads have been estimated to earn money.
Information about an ad response.
Loads and displays Google Mobile Ads rewarded ads.
Listener to be invoked when the user earned a reward.
Namespaces
API for User Messaging Platform.
Enumerations
AdErrorCode
AdErrorCode
Error codes returned by Future::error().
Will not send request because the ad object has already been used.
An attempt to load an Ad Network extras class for an ad request has failed.
The ad is not ready to be shown.
Ad is too large for the scene.
The ad is already initialized (repeat call).
The ad can not be shown when app is not in the foreground.
Will not send request because the application identifier is missing.
Error processing image url.
The request to show the Ad Inspector failed because it's already open.
An attempt to load the Ad Inspector failed.
A call to load an ad has failed due to an internal SDK error.
Will not send request because the interstitial object has already been used.
Android Ad String is invalid.
Invalid argument error.
A call to load an ad has failed due to an invalid request.
A call has failed because an ad is currently loading.
Error finding or creating a mediation ad network adapter.
The mediation response was invalid.
Attempting to pass an invalid ad size to an adapter.
A mediation ad network adapter received an ad request, but did not fill.
The adapter’s error is included as an underlyingError.
A mediation adapter failed to show the ad.
A call to load an ad has failed due to a network error.
A call to load an ad has failed because no ad was available to serve.
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).
Call completed successfully.
A debug operation failed because the device is not in test mode.
Attempted to present ad from a non-main thread.
This is an internal error which should be reported to support if encountered.
The current device’s OS is below the minimum required version.
Received invalid response.
Will not send a request because the rewarded ad object has already been used.
The ad server experienced a failure processing the request.
The request was unable to be loaded before being timed out.
The ad has not been fully initialized.
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 ()
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.
app
|
The Firebase app for which to initialize mobile ads.
|
init_result_out
|
Optional: If provided, write the basic init result here. 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'). Note that this does not include the adapter initialization status, which is returned in the Future
.
|
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.
jni_env
|
JNIEnv pointer.
|
activity
|
Activity used to start the application.
|
init_result_out
|
Optional: If provided, write the basic init result here. 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'). Note that this does not include the adapter initialization status, which is returned in the Future
.
|
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.
init_result_out
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.
parent
|
The platform-specific UI element that will host the ad inspector. For iOS this should be the window's
UIViewController
. For Android this is the Activity
Context which the GMA SDK is running in. |
listener
|
The listener will be invoked when the user closes the ad inspector UI. firebase::gma::Initialize()
. must be called prior to this function.
|
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.
is_enabled
SetRequestConfiguration
void SetRequestConfiguration ( const RequestConfiguration & request_configuration )
Sets the global RequestConfiguration that will be used for every AdRequest during the app's session.
request_configuration
Terminate
void Terminate ()
Terminate GMA.
Frees resources associated with GMA that were allocated during firebase::gma::Initialize() .