This is the AdMob extension which provides functionality to developers to add Google Ads to their game. In this wiki you can find the full available API documentation and guides necessary to get started.
Before you start using this extension make sure to follow our Setup guide. Which will get you up and running.
To get started using this extension, follow the Quick Start Guide.
For the recommended workflow see the Workflow page.
The following are the available modules from the AdMob API:
The AdMob extension is to be used alongside your Google AdMob account (web page). All the required personal ad ids and consent messages should be handled through there.
To build and deploy to iOS it’s required for the developer to install CocoaPods. (installation guide)
AdMob Console
→ Privacy and Messaging
→ Go to funding choices
→ (select your project)
→ Create (new message)
→ EU Consent
→ fill all the necessary details.This section aims to deliver an easy and simple set of examples that should help you migrate your project from a previous version of the AdMob extension into this new, updated version. The first thing to notice is that all previously named “GoogleMobileAds_*” functions have been renamed to “AdMob_*” providing a more compact naming convention which is consistent with the Google API function names outside the GameMaker environment.
The first thing to look for when creating an AdMob GameMaker project is initializing your API.
// On the previous version you would need to provide application id and
// an interstitial id to the API initialization function.
GoogleMobileAds_Init(interstitialId, applicationId);
// Optionally you could set your device to test mode to use test ads instead
// of ‘live’ ones. You would provide the enable flag and the device id.
GoogleMobileAds_UseTestAds(enable, deviceId); // <----- this is OPTIONAL
// If you are using Test Ads the ‘AdMob_SetTestDeviceId’ function needs to be
// called BEFORE initialization (no arguments are required).
AdMob_SetTestDeviceId(); // <----- this is OPTIONAL (development only)
// In the new version you just need to call the initialization method without
// any arguments, as the extension now gets the application id from the
// “extension options” automatically (Setup, 2.), and the ad ids are setup on
// a per ad-type basis.
AdMob_Initialize();
One of the first concepts requiring your attention when setting up a project using AdMob is that, depending on the user's geographic location, you might need to ask for permission to use their personal information to personalize the ads that are shown.
In previous versions you could ask the user for their consent to collect data for personalized ads using one of the following setups:
// You could forcefully show the consent form providing a privacy URL and
// options for personalized ads, non-personalized ads and ad-free version of
// your game.
GoogleMobileAds_ConsentFormShow(privacyPolicy, personalized, nonPersonalized, adFree);
OR
// You could show the consent form ONLY if the user hasn’t yet answered it.
GoogleMobileAds_ConsentUpdate(publisherId, privacyPolicy, personalized, nonPersonalized, adFree);
The new version has added functionality that requires you to:
The first steps towards requesting user consent are the following:
// First of all we need to set the Consent Mode, which can be used for
// debugging purposes to run tests as a user in a different geographic area;
// more info: Consent Mode. This function will generate an ASYNC SOCIAL EVENT.
AdMob_Consent_RequestInfoUpdate(AdMob_Consent_Mode_PRODUCTION);
After setting the consent mode we need to add some code to the ASYNC SOCIAL EVENT, to check for the events generated by the AdMob_Consent_RequestInfoUpdate function call. Here is what each event allows us to do:
Given below is the fully documented template code that you can use in your ASYNC SOCIAL EVENT:
// Early exit if there is no 'type' key defined
if (!ds_map_exists(async_load, "type")) exit;
// All the events triggered by the AdMob extension have a “type” key
// containing a string that starts with “AdMob_”.
switch(async_load[? "type"])
{
// AdMob_Consent_RequestInfoUpdate() succeeded
case "AdMob_Consent_OnRequestInfoUpdated":
// Now we need to get the consent Status, this will tell us if we
// are required to ask the user for GDPR consent.
if (AdMob_Consent_GetStatus() == AdMob_Consent_Status_REQUIRED)
// Since we are REQUIRED, we now need to load the consent
// form before we can show it. For this we use the function
// below (more info: AdMob_Consent_Load). This function call
// will also generate an ASYNC SOCIAL EVENT.
AdMob_Consent_Load();
break;
// AdMob_Consent_RequestInfoUpdate() failed
case "AdMob_Consent_OnRequestInfoUpdateFailed":
// This means there was a problem while setting the consent
// mode. Here we can add some code to deal with it.
break;
// AdMob_Consent_Load() succeeded
case "AdMob_Consent_OnLoaded":
// We have successfully loaded the consent form and we are now
// ready to show it to the user (more info: AdMob_Consent_Show)
AdMob_Consent_Show();
break;
// AdMob_Consent_Load() failed
case "AdMob_Consent_OnLoadFailed":
// This means there was a problem while loading the consent
// form. Here we can add some code to deal with it.
break;
// AdMob_Consent_Show() succeeded and the user already answered it
case "AdMob_Consent_OnShown":
// At this point we now have the consent information from the
// user. We can use both the GetStatus and GetType functions to
// get the obtained information (more info:
// AdMob_Consent_GetStatus and AdMob_Consent_GetType)
global.ConsentStatus = AdMob_Consent_GetStatus();
global.ConsentType = AdMob_Consent_GetType();
break;
}
This new version of the AdMob extension allows the developer to target ads to a specific audience. This could already be done in previous versions but the new version now has more features specifically for targeting.
In previous versions the developer could mark a user as underage ads using the following function:
// The function below classifies users as under age and only non-personalised
// ads can be shown, regardless of any other setting, and the consent form
// will not be shown.
GoogleMobileAds_ConsentSetUserUnderAge(true);
In the new version of the extension the developer is presented with more features that will help target the right kind of ads to the right kind of audience:
// The function below allows the developer to enable or disable ads for
// under-age users (much like the old version). Note that it is up to the
// developer to identify the age of the consumer.
AdMob_Targeting_UnderAge(true);
// The function below allows the developer to enable or disable ads for
// children. Note that it is up to the developer to identify the age of the
// consumer.
AdMob_Targeting_COPPA(true);
// The new version of the AdMob extension allows for even further control
// over the filtering of the ads being displayed to the user. The function
// below allows the developer to set a maximum content rating of the ads to be
// displayed (info: AdMob_Targeting_MaxAdContentRating and Content Rating constant.
AdMob_Targeting_MaxAdContentRating(AdMob_ContentRating_GENERAL);
There have been a lot of API changes since the previous version, that said let’s jump in on a quick set up for adding banner ads to your application.
Even though not all old functions map perfectly into the new API the following list should get you started with some of the changes (check the section below for more details):
The first step we should take towards adding banners is to use a manager object with the following CREATE EVENT (remember that you need to initialize the API first - Initialization)
// After API initialization we can proceed to initialize the banner options.
// This function requires a unique ad block id string that can be obtained
// from the google developer console (more info: AdMob_Banner_Init).
// This function will generate an ASYNC SOCIAL EVENT.
var banner_id = "ca-app-pub-3940256099942544/6300978111"
AdMob_Banner_Init(banner_id);
The second step requires us to make sure the API was initialized, so for this example we will use the ASYNC SOCIAL EVENT to check for the events generated by the AdMob_Initialize function call.
// Early exit if there is no 'type' key defined
if (!ds_map_exists(async_load, "type")) exit;
// All the events triggered by the AdMob extension have a “type” key
// containing a string that starts with “AdMob_”.
switch(async_load[? "type"])
{
// AdMob_Initialize() finished initializing the API
case "AdMob_OnInitialized":
// Now that we are sure that the API was initialized we can create
// our new banner on the device display.
// The function below will create a new banner of a given type,
// allowing the developer to also select the position of the
// banner (this can be either at the top or the bottom of the
// screen (more info: AdMob_Banner_Create and Banner Type).
var banner_type = AdMob_Banner_ADAPTIVE;
var bottom = true;
AdMob_Banner_Create(banner_type, bottom)
break;
// AdMob_Banner_Create() succeeded
case "AdMob_Banner_OnLoaded":
// At this point we should now have a banner on the screen.
break;
// AdMob_Banner_Create() failed
case "AdMob_Banner_OnLoadFailed":
// At this point there was a problem while creating the banner.
// Here we can add some code to deal with it.
// NOTE: Don’t try to create a banner here because it can lead to
// an infinite loop if the banner creation fails constantly.
break;
}
Interstitial ads are ads that will fill up the entire screen and need to be dismissed in order for the application to continue execution. Initial setup for interstitials is very similar to Banner ads (more info: Banner Ads). Let’s look at some code to quickly set up interstitial ads for your application.
Even though not all old functions map perfectly into the new API, the following list should get you started with some of the changes (check the section below for more details):
The first step we should take towards adding interstitials is to use a manager object with the following CREATE EVENT (remember that you need to initialize the API first - Initialization)
// After API initialization we can proceed to initialize the interstitial
// options. This requires a unique ad block id string that can be obtained
// from the google developer console. (more info: AdMob_Interstitial_Init).
// This function will generate a SOCIAL ASYNC EVENT.
var interstitial_id = "ca-app-pub-3940256099942544/1033173712"
AdMob_Interstitial_Init(interstitial_id);
The second step requires us to make sure the API was initialized so for this example we will use the ASYNC SOCIAL EVENT, to check for the events generated by the AdMob_Initialize function call.
// Early exit if there is no 'type' key defined
if (!ds_map_exists(async_load, "type")) exit;
// All the events triggered by the AdMob extension have a “type” key
// containing a string that starts with “AdMob_”.
switch(async_load[? "type"])
{
// AdMob_Initialize() finished initializing the API
case "AdMob_OnInitialized":
// Now that we are sure that the API got initialized we can load
// a new interstitial ad.(more info: AdMob_Interstitial_Load).
// This function will generate an ASYNC SOCIAL EVENT.
AdMob_Interstitial_Load();
break;
// AdMob_Interstitial_Load() succeeded
case "AdMob_Interstitial_OnLoaded":
// At this point we should now have the interstitial ad loaded and
// and we can check that using the ´AdMob_Interstitial_IsLoaded´
// function. We are now ready to show the interstitial ad to the
// user (more info: AdMob_Interstitial_Show). This function will
// generate an ASYNC SOCIAL EVENT.
AdMob_Interstitial_Show();
break;
// AdMob_Interstitial_Load() failed
case "AdMob_Interstitial_OnLoadFailed":
// At this point there was a problem while loading the
// interstitial ad. Here we can add some code to deal with it.
// NOTE: Don’t try to reload the interstitial ad here because
// it can lead to an infinite loop.
break;
// AdMob_Interstitial_Show() succeeded
case "AdMob_Interstitial_OnFullyShown":
// At this point the interstitial ad is on screen and the user is
// looking at it. Note that at this point in time your game is
// paused and will remain paused until the interstitial gets
// dismissed.
break;
// AdMob_Interstitial_Show() failed
case "AdMob_Interstitial_OnShowFailed":
// At this point the interstitial ad failed to get shown to the
// user. You can add code to deal with the problem here.
// NOTE: Don’t try to reload/show the interstitial ad here
// because it can lead to an infinite loop.
break;
// Interstitial got dismissed
case "AdMob_Interstitial_OnDismissed":
// At this point the interstitial ad got dismissed by the user and
// the game logic is running again.
break;
}
Rewarded video ads are ads that will fill up the entire screen and play a video, at the end of which the user can be rewarded in some way, and similar to interstitial ads they also need to be dismissed in order for the application to continue execution. Rewarded Video ads setup is very similar to other previous ads (more info: Banner Ads and Interstitial Ads). Let’s look at some code to quickly set up rewarded video ads on your application.
Even though not all old functions map perfectly into the new API the following list should get you started with some of the changes (check the section below for more details):
The first step we should take towards adding rewarded videos is to use a manager object with the following CREATE EVENT (remember that you need to initialize the API first - Initialization)
// After API initialization we can proceed to initialize the rewarded video
// options. This requires an unique ad block id string that can be obtained
// from the google developer console. (more info: AdMob_RewardedVideo_Init).
// This function will generate an ASYNC SOCIAL EVENT.
var rewarded_id = "ca-app-pub-3940256099942544/1033173712"
AdMob_RewardedVideo_Init(rewarded_id);
The second step requires us to make sure the API was initialized. For this example we will use the ASYNC SOCIAL EVENT, to check for the events generated by the AdMob_Initialize function call.
// Early exit if there is no 'type' key defined
if (!ds_map_exists(async_load, "type")) exit;
// All the events triggered by the AdMob extension have a “type” key
// containing a string that starts with “AdMob_”.
switch(async_load[? "type"])
{
// AdMob_Initialize() finished initializing the API
case "AdMob_OnInitialized":
// Now that we are sure that the API got initialized we can load
// a new rewarded video ad.(more info: AdMob_RewardedVideo_Load).
// This function will generate an ASYNC SOCIAL EVENT.
AdMob_RewardedVideo_Load();
break;
// AdMob_RewardedVideo_Load() succeeded
case "AdMob_RewardedVideo_OnLoaded":
// At this point we should now have the rewarded ad loaded and
// and we can check that using the ´AdMob_RewardedVideo_IsLoaded´
// function. We are now ready to show the rewarded video ad to the
// user (more info: AdMob_RewardedVideo_Show). This function will
// generate an ASYNC SOCIAL EVENT.
AdMob_RewardedVideo_Show();
break;
// AdMob_RewardedVideo_Load() failed
case "AdMob_RewardedVideo_OnLoadFailed":
// At this point there was a problem while loading the
// interstitial ad. Here we can add some code to deal with it.
// NOTE: Don’t try to reload the interstitial ad here because
// it can lead to an infinite loop.
break;
// AdMob_RewardedVideo_Show() succeeded
case "AdMob_RewardedVideo_OnFullyShown":
// At this point the rewarded video ad is playing and the user is
// looking at it. Note that at this point in time your game is
// paused and will remain paused until the rewarded video ad gets
// dismissed.
break;
// AdMob_RewardedVideo_Show() failed
case "AdMob_RewardedVideo_OnShowFailed":
// At this point the rewarded video ad failed to get shown to the
// user. You can add code to deal with the problem here.
// NOTE: Don’t try to reload/show the rewarded video here
// because it can lead to an infinite loop.
break;
// RewardedVideo got dismissed
case "AdMob_RewardedVideo_OnDismissed":
// At this point the rewarded video ad got dismissed by the user
// and the game logic is running again.
break;
// RewardedVideo triggered the reward event
case "AdMob_RewardedVideo_OnReward":
// At this point the user watched enough of the rewarded video and
// can be rewarded for it. Here we can add the reward code.
show_debug_message("You got 1000 points");
break;
}
Rewarded interstitial is a type of incentivized ad format that allows you offer rewards for ads that appear automatically during natural app transitions. Unlike rewarded ads, users aren't required to opt-in to view a rewarded interstitial, and similar to interstitial ads they also need to be dismissed in order for the application to continue execution. Rewarded interstitial ads setup is very similar to other previous ads (more info: Banner Ads and Interstitial Ads). Let’s look at some code to quickly set up rewarded interstitial ads on your application.
Even though not all old functions map perfectly into the new API the following list should get you started with some of the changes (check the section below for more details):
The first step we should take towards adding rewarded interstitial is to use a manager object with the following CREATE EVENT (remember that you need to initialize the API first - Initialization)
// After API initialization we can proceed to initialize the rewarded
// interstitial options. This requires an unique ad block id string that can
// be obtained from the google developer console. (more info:
// AdMob_RewardedInterstitial_Init).
// This function will generate an ASYNC SOCIAL EVENT.
var rewarded_interstitial_id = "ca-app-pub-3940256099942544/5354046379"
AdMob_RewardedVideo_Init(rewarded_interstitial_id);
The second step requires us to make sure the API was initialized. For this example we will use the ASYNC SOCIAL EVENT, to check for the events generated by the AdMob_Initialize function call.
// Early exit if there is no 'type' key defined
if (!ds_map_exists(async_load, "type")) exit;
// All the events triggered by the AdMob extension have a “type” key
// containing a string that starts with “AdMob_”.
switch(async_load[? "type"])
{
// AdMob_Initialize() finished initializing the API
case "AdMob_OnInitialized":
// Now that we are sure that the API got initialized we can load
// a new rewarded interstitial ad.
// (more info: AdMob_RewardedInterstitial_Load).
// This function will generate an ASYNC SOCIAL EVENT.
AdMob_RewardedInterstitial_Load();
break;
// AdMob_RewardedInterstitial_Load() succeeded
case "AdMob_RewardedInterstitial_OnLoaded":
// At this point we should now have the rewarded ad loaded and
// and we can check that using the
// ´AdMob_RewardedInterstitial_IsLoaded´ function. We are now
// ready to show the rewarded interstitial ad to the user
// (more info: AdMob_RewardedInterstitial_Show).
// This function will generate an ASYNC SOCIAL EVENT.
AdMob_RewardedInterstitial_Show();
break;
// AdMob_RewardedInterstitial_Load() failed
case "AdMob_RewardedInterstitial_OnLoadFailed":
// At this point there was a problem while loading the
// interstitial ad. Here we can add some code to deal with it.
// NOTE: Don’t try to reload the interstitial ad here because
// it can lead to an infinite loop.
break;
// AdMob_RewardedInterstitial_Show() succeeded
case "AdMob_RewardedInterstitial_OnFullyShown":
// At this point the rewarded video ad is playing and the user is
// looking at it. Note that at this point in time your game is
// paused and will remain paused until the rewarded video ad gets
// dismissed.
break;
// AdMob_RewardedInterstitial_Show() failed
case "AdMob_RewardedInterstitial_OnShowFailed":
// At this point the rewarded video ad failed to get shown to the
// user. You can add code to deal with the problem here.
// NOTE: Don’t try to reload/show the rewarded video here
// because it can lead to an infinite loop.
break;
// RewardedInterstitial got dismissed
case "AdMob_RewardedInterstitial_OnDismissed":
// At this point the rewarded interstitial ad got dismissed by the
// user and the game logic is running again.
break;
// RewardedInterstitial triggered the reward event
case "AdMob_RewardedInterstitial_OnReward":
// At this point the user watched enough of the rewarded video and
// can be rewarded for it. Here we can add the reward code.
show_debug_message("You got 1000 points");
break;
}
This is the recommended workflow for using AdMob extension functions calls both on Android and iOS.
This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
This function initializes the Google AdMob API and should be called at the start of your game.
Syntax:
gml AdMob_Initialize()
Returns:
N/A
This function tells the app to use test ads instead of “live” ads, essential for testing whether your ads work without generating potentially fraudulent click-throughs. This function should be called BEFORE calling AdMob_Initialize.
Syntax:
gml AdMob_SetTestDeviceId()
Returns:
N/A
Enable the paid load callbacks, NOTE: You should enable this feature in your console too https://support.google.com/admob/answer/11322405
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
gml AdMob_Events_OnPaidEvent(enable)
Argument | Type | Description |
---|---|---|
enable | Real |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "AdMob_OnPaidEvent" |
mediation_adapter_class_name | String | The mediation adapter class name of the ad network that loaded the ad. |
unit_id | String | identifier of the ad |
ad_type | String | 'Banner","Interstitial","Rewarded","RewardedInterstitial" or "AppOpen" |
micros | Real | The ad's value in micro-units, where 1,000,000 micro-units equal one unit of the currency. |
currency_code | String | The value's ISO 4217 currency code. |
precision | AdMobAdValuePrecision | The precision type of the reported ad value. |
ad_source_name | String | Gets the ad source representing the specific ad network that serves the impression. For campaigns, Mediated House Ads is returned for a mediated ads campaign goal type, and Reservation Campaign is returned for impression and click goal types. See Ad sources for the list of possible ad source names when an ad network serves the ad. |
ad_source_id | String | Gets the ad source ID associated with this adapter response. For campaigns, 6060308706800320801 is returned for a mediated ads campaign goal type, and 7068401028668408324 is returned for impression and click goal types. See Ad sources for the list of possible ad source IDs when an ad network serves the ad. |
ad_source_instance_name | String | Gets the ad source instance name associated with this adapter response. |
ad_source_instance_id | String | Gets the ad source instance ID associated with this adapter response. |
This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
Requests a consent information update (this needs to be called prior to AdMob_Consent_Load)
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
gml AdMob_Consent_RequestInfoUpdate(mode)
Argument | Type | Description |
---|---|---|
mode | AdMobConsentMode |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "AdMob_Consent_OnRequestInfoUpdated" |
Key | Type | Description |
---|---|---|
type | String | "AdMob_Consent_OnRequestInfoUpdateFailed" |
errorMessage | String | the error code responsible for the failure |
errorCode | Real | the error message of the error code |
Allows to set the mode of the consent request being used. This function allows you to debug different regions and EEA and NON-EEA and should be passed in as a 'AdMob_Consent_Mode_*' constant. This function should be called before AdMob_Consent_GetStatus and AdMob_Consent_GetType in order to get the correct output from both functions.
!INFO Requires a previous call to AdMob_Consent_RequestInfoUpdate
Syntax:
gml AdMob_Consent_GetStatus()
Returns:
Returns the answer given by the user to a previous GDPR consent request.
Syntax:
gml AdMob_Consent_GetType()
Returns:
Checks whether or not the GDPR consent form is available on this device.
Syntax:
gml AdMob_Consent_IsFormAvailable()
Returns:
N/A
Loads the consent form into memory so it can be displayed to the user. If you do not call this function before trying to show the GDPR consent, nothing will be shown.
!INFO Requires a previous call to AdMob_Consent_RequestInfoUpdate
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
gml AdMob_Consent_Load()
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "AdMob_Consent_OnLoaded" |
Key | Type | Description |
---|---|---|
type | String | "AdMob_Consent_OnLoadFailed" |
errorMessage | String | the error code responsible for the failure |
errorCode | Real | the error message of the error code |
Shows the consent form to the user. If you do not call the AdMob_Consent_Load function before trying to show the GDPR consent, nothing will be shown.
!INFO Requires a previous call to AdMob_Consent_Load
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
gml AdMob_Consent_Show()
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "AdMob_Consent_OnShown" |
Key | Type | Description |
---|---|---|
type | String | "AdMob_Consent_OnShowFailed" |
errorMessage | String | the error code responsible for the failure |
errorCode | Real | the error message of the error code |
This function resets the consent status flag.
Syntax:
gml AdMob_Consent_Reset()
Returns:
N/A
This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
Toggles on/off ads for children. This function should be called BEFORE calling AdMob_Initialize.
!WARNING Should be called before AdMob_Initialize.
Syntax:
gml AdMob_Targeting_COPPA(COPPA)
Argument | Type | Description |
---|---|---|
COPPA | Boolean |
Returns:
N/A
Toggles on/off ads for under aged users. This function should be called BEFORE calling AdMob_Initialize.
!WARNING Should be called before AdMob_Initialize.
Syntax:
gml AdMob_Targeting_UnderAge(underAge)
Argument | Type | Description |
---|---|---|
underAge | Boolean |
Returns:
N/A
Allows for setting the maximum content rating of the ads to be displayed. This function should be called BEFORE calling AdMob_Initialize.
!WARNING Should be called before AdMob_Initialize.
Syntax:
gml AdMob_Targeting_MaxAdContentRating(contentRating)
Argument | Type | Description |
---|---|---|
contentRating | AdMobContentRating |
Returns:
N/A
This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
⛔ This function was deprecated with version 1.3.0.
Initializes the target identifier for banner functions.
!NOTE Please refer to AdMob_Banner_Set_AdUnit for more information.
Syntax:
gml AdMob_Banner_Init(adUnitId)
Argument | Type | Description |
---|---|---|
adUnitId | String |
Returns:
N/A
Versioning:
1.3.0
- ⛔ This function was deprecated.Set the target identifier for banner functions, Banner funcitons DOESN'T allow multiple preloaded identifiers.
Syntax:
gml AdMob_Banner_Set_AdUnit(adUnitId)
Argument | Type | Description |
---|---|---|
adUnitId | String |
Returns:
N/A
Versioning:
1.3.0
- This function was introduced.This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
gml AdMob_Banner_Create(size, bottom)
Argument | Type | Description |
---|---|---|
size | Real | The type of the banner to be displayed. |
bottom | Boolean | Whether the banner should be placed at the bottom of the display. |
Returns:
Triggers:
This event is triggered is the awaited task succeeds.
Key | Type | Description |
---|---|---|
type | String | "AdMob_Banner_OnLoaded" |
This event is triggered is the awaited task fails.
Key | Type | Description |
---|---|---|
type | String | "AdMob_Banner_OnLoadFailed" |
errorMessage | String | the error code responsible for the failure |
errorCode | Real | the error message of the error code |
This function can be used to get the width of the currently loaded banner ad block. The value returned is in pixels. NOTE: This function returns the width in screen pixels, it’s up to the developer to convert the value to the correct scale according to the render target being used.
Syntax:
gml AdMob_Banner_GetWidth()
Returns:
This function can be used to get the height of the currently loaded banner ad block. The value returned is in pixels. NOTE: This function returns the height in screen pixels, it’s up to the developer to convert the value to the correct scale according to the render target being used.
Syntax:
gml AdMob_Banner_GetHeight()
Returns:
This function can be used to move a banner that has been previously added. You supply a boolean that will determine if the banner should be placed at the bottom or at the top of the display.
Syntax:
gml AdMob_Banner_Move(bottom)
Argument | Type | Description |
---|---|---|
bottom | Boolean | Whether the banner should be placed at the bottom of the display. |
Returns:
This function can be used to show the currently active, but hidden, banner ad block. When called, the banner will be shown to the user again and will be able to receive input. You can hide the banner again at any time using the AdMob_Banner_Hide function.
Syntax:
gml AdMob_Banner_Show()
Returns:
This function can be used to hide the currently active banner ad block. When called, the banner will be removed from the user’s view and will no longer receive input. You can show the banner again at any time using the AdMob_Banner_Show function.
Syntax:
gml AdMob_Banner_Hide()
Returns:
This function will remove the currently active banner from the app. If you call this function then want to show ads again, you must call the AdMob_Banner_Create function first to add a new banner to the display.
Syntax:
gml AdMob_Banner_Remove()
Returns:
This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
⛔ This function was deprecated with version 1.3.0.
Initializes the target identifier for interstitial ad functions.
!NOTE Please refer to AdMob_Interstitial_Set_AdUnit for more information.
Syntax:
gml AdMob_Interstitial_Init(adUnitId)
Argument | Type | Description |
---|---|---|
adUnitId | String |
Returns:
N/A
Versioning:
1.3.0
- ⛔ This function was deprecated.Set the target identifier for interstitial functions, Interstitials functions allow multiple identifiers
Syntax:
gml AdMob_Interstitial_Set_AdUnit(adUnitId)
Argument | Type | Description |
---|---|---|
adUnitId | String |
Returns:
N/A
Versioning:
1.3.0
- This function was introduced.Release Interstitial load instances (passing -1 will free all the loaded instances).
Syntax:
gml Admob_Interstitial_Free_Load_Instances(count)
Argument | Type | Description |
---|---|---|
count | Real |
Returns:
N/A
Versioning:
1.3.0
- This function was introduced.Set the max number of Interstitial load instances, this allow present consecutiva ads. Default value is 1.
Syntax:
gml Admob_Interstitial_Max_Instances(count)
Argument | Type | Description |
---|---|---|
count | Real |
Returns:
N/A
Versioning:
1.3.0
- This function was introduced.This function should be called when you want to load an interstitial ad. Calling it will send a request to the ad server to provide an interstitial ad, which will then be loaded into the app for display. This function does not show the ad, just stores it in memory ready for being shown. If you do not call this function before trying to show an ad, nothing will be shown. Note that you can check whether an interstitial is loaded or not using the function AdMob_Interstitial_IsLoaded.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
gml AdMob_Interstitial_Load()
Returns:
Triggers:
This event is triggered is the awaited task succeeds.
Key | Type | Description |
---|---|---|
type | String | "AdMob_Interstitial_OnLoaded" |
unit_id | String | Unit identifier of the advertisment |
This event is triggered is the awaited task fails.
Key | Type | Description |
---|---|---|
type | String | "AdMob_Interstitial_OnLoadFailed" |
unit_id | String | Unit identifier of the advertisment |
errorMessage | String | the error code responsible for the failure |
errorCode | Real | the error message of the error code |
This function will show the interstitial ad, if one is available and loaded. You can check whether an ad is available using the function AdMob_Interstitial_IsLoaded. Note that while an interstitial is being shown, your app will be put into the background and will effectively be “paused”.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
gml AdMob_Interstitial_Show()
Returns:
Triggers:
This event is triggered is the ad view is closed by the user.
Key | Type | Description |
---|---|---|
type | String | "AdMob_Interstitial_OnDismissed" |
unit_id | String | Unit identifier of the advertisment |
This event is triggered is the awaited task fails.
Key | Type | Description |
---|---|---|
type | String | "AdMob_Interstitial_OnShowFailed" |
unit_id | String | Unit identifier of the advertisment |
errorMessage | String | the error code responsible for the failure |
errorCode | Real | the error message of the error code |
This event is triggered is the awaited task succeeds.
Key | Type | Description |
---|---|---|
type | String | "AdMob_Interstitial_OnFullyShown" |
unit_id | String | Unit identifier of the advertisment |
This function will return whether or not the interstitial ad is loaded.
Syntax:
gml AdMob_Interstitial_IsLoaded()
Returns:
Return the number of Interstitial load instances are ready.
Syntax:
gml AdMob_Interstitial_Instances_Count()
Returns:
Versioning:
1.3.0
- This function was introduced.This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
⛔ This function was deprecated with version 1.3.0.
Initializes the target identifier for rewarded video ad functions.
!NOTE Please refer to AdMob_RewardedVideo_Set_AdUnit for more information.
Syntax:
gml AdMob_RewardedVideo_Init(adUnitId)
Argument | Type | Description |
---|---|---|
adUnitId | String |
Returns:
N/A
Versioning:
1.3.0
- ⛔ This function was deprecated.Set the target identifier for rewarded video functions, Rewarded video funcitons allow multiple identifiers
Syntax:
gml AdMob_RewardedVideo_Set_AdUnit(adUnitId)
Argument | Type | Description |
---|---|---|
adUnitId | String |
Returns:
N/A
Versioning:
1.3.0
- This function was introduced.Release Rewarded Video load instances (passing -1 will free all the loaded instances).
Syntax:
gml AdMob_RewardedVideo_Free_Load_Instances(count)
Argument | Type | Description |
---|---|---|
count | Real |
Returns:
N/A
Versioning:
1.3.0
- This function was introduced.Set the max number of Rewarded Video load instances, this allow present consecutiva ads. Default value is 1.
Syntax:
gml AdMob_RewardedVideo_Max_Instances(count)
Argument | Type | Description |
---|---|---|
count | Real |
Returns:
N/A
Versioning:
1.3.0
- This function was introduced.This function should be called when you want to load a rewarded video ad. Calling it will send a request to the ad server to provide a rewarded ad, which will then be loaded into the app for display. This function does not show the ad, just stores it in memory ready for showing. If you do not call this function before trying to show an ad, nothing will be shown. Note that you can check whether a rewarded video is loaded or not using the function AdMob_RewardedVideo_IsLoaded.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
gml AdMob_RewardedVideo_Load()
Returns:
Triggers:
This event is triggered is the awaited task fails.
Key | Type | Description |
---|---|---|
type | String | "AdMob_RewardedVideo_OnLoadFailed" |
unit_id | String | Unit identifier of the advertisment |
errorMessage | String | the error code responsible for the failure |
errorCode | Real | the error message of the error code |
This event is triggered is the awaited task succeeds.
Key | Type | Description |
---|---|---|
type | String | "AdMob_RewardedVideo_OnLoaded" |
unit_id | String | Unit identifier of the advertisment |
This function will show the rewarded video ad, if one is available and loaded. You can check whether an ad has previously been loaded using the function AdMob_RewardedVideo_IsLoaded. Note that while a rewarded video ad is being shown, your app will be put into the background and will effectively be “paused”.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
gml AdMob_RewardedVideo_Show()
Returns:
Triggers:
This event is triggered when the ad view is closed by the user.
Key | Type | Description |
---|---|---|
type | String | "AdMob_RewardedVideo_OnDismissed" |
unit_id | String | Unit identifier of the advertisment |
This event is triggered is the awaited task fails.
Key | Type | Description |
---|---|---|
type | String | "AdMob_RewardedVideo_OnShowFailed" |
unit_id | String | Unit identifier of the advertisment |
errorMessage | String | the error code responsible for the failure |
errorCode | Real | the error message of the error code |
This event is triggered is the awaited task succeeds.
Key | Type | Description |
---|---|---|
type | String | "AdMob_RewardedVideo_OnFullyShown" |
unit_id | String | Unit identifier of the advertisment |
This event is triggered if the user should be rewarded.
Key | Type | Description |
---|---|---|
type | String | "AdMob_RewardedVideo_OnReward" |
unit_id | String | Unit identifier of the advertisment |
This function will return whether the rewarded video ad has been loaded or not.
Syntax:
gml AdMob_RewardedVideo_IsLoaded()
Returns:
Return the number of Rewarded video load instances are ready.
Syntax:
gml AdMob_RewardedVideo_Instances_Count()
Returns:
Versioning:
1.3.0
- This function was introduced.This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
⛔ This function was deprecated with version 1.3.0.
Initializes the target identifier for rewarded interstitial ad functions.
!NOTE Please refer to AdMob_RewardedInterstitial_Set_AdUnit for more information.
Syntax:
gml AdMob_RewardedInterstitial_Init(adUnitId)
Argument | Type | Description |
---|---|---|
adUnitId | String |
Returns:
N/A
Versioning:
1.3.0
- ⛔ This function was deprecated.Set the target identifier for rewarded interstitial functions, Rewarded interstitial funcitons allow multiple identifiers
Syntax:
gml AdMob_RewardedInterstitial_Set_AdUnit(adUnitId)
Argument | Type | Description |
---|---|---|
adUnitId | String |
Returns:
N/A
Versioning:
1.3.0
- This function was introduced.Release Rewarded Interstitial load instances (passing -1 will free all the loaded instances).
Syntax:
gml AdMob_RewardedInterstitial_Free_Load_Instances(count)
Argument | Type | Description |
---|---|---|
count | Real |
Returns:
N/A
Versioning:
1.3.0
- This function was introduced.Set the max number of Rewarded Insterstitials load instances, this allow present consecutiva ads. Default value is 1.
Syntax:
gml AdMob_RewardedInterstitial_Max_Instances(count)
Argument | Type | Description |
---|---|---|
count | Real |
Returns:
N/A
Versioning:
1.3.0
- This function was introduced.This function should be called when you want to load a rewarded interstitial ad. Calling it will send a request to the ad server to provide a rewarded ad, which will then be loaded into the app for display. This function does not show the ad, just stores it in memory ready for showing. If you do not call this function before trying to show an ad, nothing will be shown. Note that you can check whether a rewarded interstitial is loaded or not using the function AdMob_RewardedInterstitial_IsLoaded.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
gml AdMob_RewardedInterstitial_Load()
Returns:
Triggers:
This event is triggered is the awaited task fails.
Key | Type | Description |
---|---|---|
type | String | "AdMob_RewardedInterstitial_OnLoadFailed" |
unit_id | String | Unit identifier of the advertisment |
errorMessage | String | the error code responsible for the failure |
errorCode | Real | the error message of the error code |
This event is triggered is the awaited task succeeds.
Key | Type | Description |
---|---|---|
type | String | "AdMob_RewardedInterstitial_OnLoaded" |
unit_id | String | Unit identifier of the advertisment |
This function will show the rewarded video ad, if one is available and loaded. You can check whether an ad has previously been loaded using the function AdMob_RewardedInterstitial_IsLoaded. Note that while a rewarded interstitial ad is being shown, your app will be put into the background and will effectively be “paused”.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
gml AdMob_RewardedInterstitial_Show()
Returns:
Triggers:
This event is triggered when the ad view is closed by the user.
Key | Type | Description |
---|---|---|
type | String | "AdMob_RewardedInterstitial_OnDismissed" |
unit_id | String | Unit identifier of the advertisment |
This event is triggered is the awaited task fails.
Key | Type | Description |
---|---|---|
type | String | "AdMob_RewardedInterstitial_OnShowFailed" |
unit_id | String | Unit identifier of the advertisment |
errorMessage | String | the error code responsible for the failure |
errorCode | Real | the error message of the error code |
This event is triggered is the awaited task succeeds.
Key | Type | Description |
---|---|---|
type | String | "AdMob_RewardedInterstitial_OnFullyShown" |
unit_id | String | Unit identifier of the advertisment |
This event is triggered if the user should be rewarded.
Key | Type | Description |
---|---|---|
type | String | "AdMob_RewardedInterstitial_OnReward" |
unit_id | String | Unit identifier of the advertisment |
This function will return whether the rewarded interstitial ad has been loaded or not.
Syntax:
gml AdMob_RewardedInterstitial_IsLoaded()
Returns:
Return the number of Rewarded Interstitial load instances are ready.
Syntax:
gml AdMob_RewardedInterstitial_Instances_Count()
Returns:
Versioning:
1.3.0
- This function was introduced.This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
⛔ This function was deprecated with version 1.3.0.
Initializes the target identifier for app open ads functions.
!NOTE Please refer to AdMob_AppOpenAd_Set_AdUnit for more information.
Syntax:
gml AdMob_AppOpenAd_Init(adUnitId)
Argument | Type | Description |
---|---|---|
adUnitId | String |
Returns:
N/A
Versioning:
1.3.0
- ⛔ This function was deprecated.Set the target identifier for app open ads functions, app open ads funcitons doesn't allow multiple pre-loaded identifiers.
Syntax:
gml AdMob_AppOpenAd_Set_AdUnit(adUnitId)
Argument | Type | Description |
---|---|---|
adUnitId | String |
Returns:
N/A
Versioning:
1.3.0
- This function was introduced.Enable show App Open Ads when game resumes from background.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
gml AdMob_AppOpenAd_Enable(orientation)
Argument | Type | Description |
---|---|---|
orientation | Real |
Returns:
Triggers:
This event is triggered when the ad view is closed by the user.
Key | Type | Description |
---|---|---|
type | String | "AdMob_AppOpenAd_OnDismissed" |
unit_id | String | Unit identifier of the advertisment |
This event is triggered is the awaited task fails.
Key | Type | Description |
---|---|---|
type | String | "AdMob_AppOpenAd_OnShowFailed" |
unit_id | String | Unit identifier of the advertisment |
errorMessage | String | the error code responsible for the failure |
errorCode | Real | the error message of the error code |
This event is triggered is the awaited task succeeds.
Key | Type | Description |
---|---|---|
type | String | "AdMob_AppOpenAd_OnFullyShown" |
unit_id | String | Unit identifier of the advertisment |
Versioning:
1.3.0
- This function was introduced.Disable show App Open Ads when game resume
Syntax:
gml AdMob_AppOpenAd_Disable()
Returns:
Versioning:
1.3.0
- This function was introduced.Return the true if app open ads are enabled. Otherwise return false.
Syntax:
gml AdMob_AppOpenAd_IsEnabled()
Returns:
This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
This method provides control over the sound’s loudness when playing rewarded video ads. This method will trigger a reload of the current Interstitial and RewardedVideo ads.
Syntax:
gml AdMob_Settings_SetVolume(value)
Argument | Type | Description |
---|---|---|
value | Real | The amount to set the volume to. |
Returns:
N/A
This method provides control over muting the sound when playing rewarded video ads. This method will trigger a reload of the current Interstitial and RewardedVideo ads.
Syntax:
gml AdMob_Settings_SetMuted(value)
Argument | Type | Description |
---|---|---|
value | Real |
Returns:
N/A
The following are the available constanst to use with the AdMob API.
This module includes a set of predefined constants that can be utilized for various purposes. Browse through the available constants to find values relevant to your needs and enhance the efficiency of your code.
These set of constants represent the values errors values that can return from the AdMob function calls.
These constants are referenced by the following functions:
Member | Description |
---|---|
ADMOB_OK |
There were no errors. |
ADMOB_ERROR_NOT_INITIALIZED |
The AdMob extension needs to be initialized prior to this call |
ADMOB_ERROR_INVALID_AD_ID |
The provided ad unit id is not valid. |
ADMOB_ERROR_AD_LIMIT_REACHED |
The limit of loaded ads for this specific type was reached. |
ADMOB_ERROR_NO_ADS_LOADED |
There are no loaded ads to be shown for this specific type. |
ADMOB_ERROR_NO_ACTIVE_BANNER_AD |
There is no active banner ad. |
ADMOB_ERROR_ILLEGAL_CALL |
The call you are trying to execute is illegal (used for functions that need to be called prior to initialization). |
These set of constants represent precision type of the reported ad value.
These constants are referenced by the following functions:
Member | Description |
---|---|
ADMOB_ADVALUE_PRECISION_UNKNOWN |
An unknown precision type. |
ADMOB_ADVALUE_PRECISION_ESTIMATED |
An ad value estimated from aggregated data. |
ADMOB_ADVALUE_PRECISION_PRECISE |
The precise value paid for this ad. |
ADMOB_ADVALUE_PRECISION_PUBLISHER_PROVIDED |
A publisher-provided ad value, such as manual CPMs in a mediation group. |
These set of constants represent the various types of available banners.
Member | Description |
---|---|
AdMob_Banner_NORMAL |
Normal sized banner (320x50 dp) |
AdMob_Banner_LARGE |
Large sized banner (320x100 dp) |
AdMob_Banner_MEDIUM |
IAB medium rectangle (300x250 dp) |
AdMob_Banner_FULL |
IAB full-size banner (468x60 dp - tablets only) |
AdMob_Banner_LEADERBOARD |
IAB leaderboard (728x90 dp - tablets only) |
AdMob_Banner_SMART |
A dynamic size banner (deprecated, see AdMob_Banner_ADAPTIVE ) |
AdMob_Banner_ADAPTIVE |
A dynamically sized banner |
These set of constants represent the various types of possible content ratings for ads.
These constants are referenced by the following functions:
Member | Description |
---|---|
AdMob_ContentRating_GENERAL |
Content suitable for general audiences. |
AdMob_ContentRating_PARENTAL_GUIDANCE |
Content suitable for most audiences with parental guidance. |
AdMob_ContentRating_TEEN |
Content suitable for teen and older audiences. |
AdMob_ContentRating_MATURE_AUDIENCE |
Content suitable only for mature audiences. |
These set of constants represent the various consent status.
These constants are referenced by the following functions:
Member | Description |
---|---|
AdMob_Consent_Status_UNKNOWN |
Consent status is unknown. |
AdMob_Consent_Status_NOT_REQUIRED |
User consent not required. |
AdMob_Consent_Status_REQUIRED |
User consent required but not yet obtained. |
AdMob_Consent_Status_OBTAINED |
User consent obtained. Personalized vs non-personalized undefined. |
These set of constants represent the given consent type.
These constants are referenced by the following functions:
Member | Description |
---|---|
AdMob_Consent_Type_UNKNOWN |
Consent type is unknown (before consent was requested). |
AdMob_Consent_Type_NON_PERSONALIZED |
Consent was given for non-personalized ads. |
AdMob_Consent_Type_PERSONALIZED |
Consent was given for personalized ads. |
AdMob_Consent_Type_DECLINED |
Consent was declined for any kind of ads. |
These set of constants represent the consent mode (these are used for testing porpuses).
These constants are referenced by the following functions:
Member | Description |
---|---|
AdMob_Consent_Mode_DEBUG_GEOGRAPHY_DISABLED |
Debug geography disabled. |
AdMob_Consent_Mode_DEBUG_GEOGRAPHY_EEA |
Geography appears as in EEA for debug devices. |
AdMob_Consent_Mode_DEBUG_GEOGRAPHY_NOT_EEA |
Geography appears as not in EEA for debug devices. |
AdMob_Consent_Mode_PRODUCTION |
Same as AdMob_Consent_Mode_DEBUG_GEOGRAPHY_DISABLED , used for production. |