Enables AdMob functionality on Godot apps that are exported to the iOS platform and allows displaying of Admob ads.
For Android version, visit https://github.com/cengiz-pz/godot-android-admob-plugin .
Follow instructions on the following page to prepare for iOS export:
Create an AdMob account at the following link:
- Google AdMob
- create an app in AdMob console
- create ad(s) for your app via the AdMob console
- if needed, create consent form(s) for your app via the AdMob console
Before installing this plugin, make sure to uninstall any previous versions of the same plugin.
If installing both iOS and Android versions of the plugin in the same project, then make sure that both versions use the same addon interface version.
There are 2 ways to install the Admob plugin into your project:
- Through the Godot Editor's AssetLib
- Manually by downloading archives from Github
Steps:
- search for and select the
Admobplugin in Godot Editor - click
Downloadbutton - on the installation dialog...
- keep
Change Install Foldersetting pointing to your project's root directory - keep
Ignore asset rootcheckbox checked - click
Installbutton
- keep
- enable the addon via the
Pluginstab ofProject->Project Settings...menu, in the Godot Editor - enable the plugin via the
iOSsection ofProject->Export...menu, in the Godot Editor
When installing via AssetLib, the installer may display a warning that states "[x number of] files conflict with your project and won't be installed." You can ignore this warning since both versions use the same addon code.
Steps:
- download release archive from Github
- unzip the release archive
- copy to your Godot project's root directory
- enable the addon via the
Pluginstab ofProject->Project Settings...menu, in the Godot Editor - enable the plugin via the
iOSsection ofProject->Export...menu, in the Godot Editor
App Tracking Transparency, or ATT for short, is Apple's opt-in privacy framework that requires all iOS apps to ask users for permission to share their data. This is done in the form of a popup where users can either consent or deny tracking.
- To enable ATT in your app
- Enter a descriptive text that will be displayed on the ATT dialog in your
Admobnode'satt_textfield. - Call
Admobnode'srequest_tracking_authorization()method. - Handle
Admobnode'stracking_authorization_grantedandtracking_authorization_deniedsignals.
- Enter a descriptive text that will be displayed on the ATT dialog in your
- If the user initially rejects the tracking request, then later on you can check if the user changed their mind and allow them to change their decision by opening the system app settings using the
Admobnode'sopen_app_settings()method.
-
Add
Admobnode to your main scene and populate the ID fields of the node- Debug IDs will only be used when your Godot app is run in debug mode
- Real IDs will only be used when the
is_realfield of the node is set totrue
-
register listeners for one or more of the following signals of the
Admobnode:initialization_completed(status_data: InitializationStatus)banner_ad_loaded(ad_id: String)banner_ad_failed_to_load(ad_id: String, error_data: LoadAdError)banner_ad_refreshed(ad_id: String)banner_ad_clicked(ad_id: String)banner_ad_impression(ad_id: String)banner_ad_opened(ad_id: String)banner_ad_closed(ad_id: String)interstitial_ad_loaded(ad_id: String)interstitial_ad_failed_to_load(ad_id: String, error_data: LoadAdError)interstitial_ad_refreshed(ad_id: String)interstitial_ad_impression(ad_id: String)interstitial_ad_clicked(ad_id: String)interstitial_ad_showed_full_screen_content(ad_id: String)interstitial_ad_failed_to_show_full_screen_content(ad_id: String, error_data: AdError)interstitial_ad_dismissed_full_screen_content(ad_id: String)rewarded_ad_loaded(ad_id: String)rewarded_ad_failed_to_load(ad_id: String, error_data: LoadAdError)rewarded_ad_impression(ad_id: String)rewarded_ad_clicked(ad_id: String)rewarded_ad_showed_full_screen_content(ad_id: String)rewarded_ad_failed_to_show_full_screen_content(ad_id: String, error_data: AdError)rewarded_ad_dismissed_full_screen_content(ad_id: String)rewarded_ad_user_earned_reward(ad_id: String, reward_data: RewardItem)rewarded_interstitial_ad_loaded(ad_id: String)rewarded_interstitial_ad_failed_to_load(ad_id: String, error_data: LoadAdError)rewarded_interstitial_ad_impression(ad_id: String)rewarded_interstitial_ad_clicked(ad_id: String)rewarded_interstitial_ad_showed_full_screen_content(ad_id: String)rewarded_interstitial_ad_failed_to_show_full_screen_content(ad_id: String, error_data: AdError)rewarded_interstitial_ad_dismissed_full_screen_content(ad_id: String)rewarded_interstitial_ad_user_earned_reward(ad_id: String, reward_data: RewardItem)consent_form_loadedconsent_form_dismissed(error_data: FormError)consent_form_failed_to_load(error_data: FormError)consent_info_updatedconsent_info_update_failed(error_data: FormError)tracking_authorization_grantedtracking_authorization_denied
-
initialize the plugin
- call the
initialize()method of theAdmobnode - wait for the
initialization_completedsignal
- call the
-
use one or more of the following
load_*()methods to load ads from theAdmobnode:load_banner_ad(ad_request: LoadAdRequest)load_interstitia_adl(ad_request: LoadAdRequest)load_rewarded_ad(ad_request: LoadAdRequest)load_rewarded_interstitial_ad(ad_request: LoadAdRequest)
-
the
Admobnode will emit the following signals once ads have been loaded or failed to load:banner_ad_loaded(ad_id: String)banner_ad_failed_to_load(ad_id: String, error_data: LoadAdError)interstitial_ad_loaded(ad_id: String)interstitial_ad_failed_to_load(ad_id: String, error_data: LoadAdError)rewarded_ad_loaded(ad_id: String)rewarded_ad_failed_to_load(ad_id: String, error_data: LoadAdError)rewarded_interstitial_ad_loaded(ad_id: String)rewarded_interstitial_ad_failed_to_load(ad_id: String, error_data: LoadAdError)
-
once ads have been loaded, call corresponding
show_*()method from theAdmobnode with thead_idreceived:show_banner_ad(ad_id: String)show_interstitial_ad(ad_id: String)show_rewarded_ad(ad_id: String)show_rewarded_interstitial_ad(ad_id: String)
iOS export requires several configuration settings.
In order to enable file-based export configuration, an export.cfg file should be placed in the addons/AdmobPlugin directory with the file contents formatted as in the example below:
[General]
is_real = false
[Debug]
app_id = "ca-app-pub-3940256099942544~3347511713"
[Release]
app_id = "ca-app-pub-3940256099942544~3347511713"
[ATT]
att_enabled = true
att_text = "My ATT text."
The is_real and app_id configuration items are mandatory and if not found in the export.cfg file, then the plugin will fall back to node-based configuration.
If export.cfg file is not found or file-based configuration fails, then the plugin will attempt to load node-based configuration.
During iOS export, the plugin searches for an Admob node in the scene that is open in the Godot Editor. If not found, then the plugin searches for an Admob node in the project's main scene. Therefore;
- Make sure that the scene that contains the
Admobnode is selected in the Godot Editor when building and exporting for iOS, or - Make sure that your Godot project's main scene contains an
Admobnode
If your game crashes due to missing APP ID, then make sure that you enter your Admob APP ID in the Admob node and pay attention to the iOS Export section.
XCode logs are one of the best tools for troubleshooting unexpected behavior. View XCode logs while running your game to troubleshoot any issues.
Refer to Godot's Troubleshooting Guide.
Developed by Cengiz
Based on Godot iOS Plugin Template
Original repository: Godot iOS Admob Plugin
This section provides information on how to build the plugin for contributors.
- Run
./script/build.sh -A <godot version>initially to run a full build - Run
./script/build.sh -cgA <godot version>to clean, redownload Godot, and rebuild - Run
./script/build.sh -cato clean and build without redownloading Godot - Run
./script/build.sh -cb -z4.0to clean and build plugin without redownloading Godot and package in a zip archive as version 4.0 - Run
./script/build.sh -hfor more information on the build script
- Run
./script/install.sh -t <target directory> -z <path to zip file>install plugin to a Godot project. - Example
./script/install.sh -t demo -z bin/release/AdmobPlugin-v4.0.zipto install to demo app.
git submodule add -b main --force --name addon https://github.com/cengiz-pz/godot-admob-addon.git addon
- Remove
addondirectory - Run
git submodule update --remote --merge
Library archives will be created in the bin/release directory.
