Support my work: Follow me on Twitter and add me on LinkedIn!
This plugin implements the Google Consent SDK for Godot 3.3. The GDPR requires Google App developers to obtain user consent before displaying any ads served by AdMob or its ad technology providers.
The main features of the plugin are:
- Verifying that consent for personalized or non-personalized ads has been obtained
- Detecting when consent has to be obtained again because the list of ad technology providers changed
- Displaying a customizable form to obtain consent
- Follow the official documentation to configure, install and enable an Android Custom Build.
- Download the consent plugin from the release tab.
- Extract the contents of ConsentPlugin.7z to
res://android/plugins
- Additionally you will need another plugin for serving ads via AdMob. I have used Shin-NiL's Godot-Android-Admob-Plugin.
- Call the consent plugin from a godot script (see chapter below).
- When exporting your game via a preset in
Project>Export...
make sure that theUse Custom Build
andConsent Plugin
is checked.
Check if the singleton instance of ConsentPlugin
is available. Then connect the signals of the plugin.
func check_consent():
if Engine.has_singleton("ConsentPlugin"):
consent = Engine.get_singleton("ConsentPlugin")
# connect signals
consent.connect("consent_info_updated",self,"consent_info_updated")
consent.connect("failed_to_update_consent_information",self,"failed_to_update_consent_information")
consent.connect("consent_form_loaded",self,"consent_form_loaded")
consent.connect("consent_form_opened",self,"consent_form_opened")
consent.connect("consent_form_closed",self,"consent_form_closed")
consent.connect("consent_form_error",self,"consent_form_error")
The Google Consent SDK requires that the consent status is initialized/updated:
#Pass your own publisher ids as a string array to the plugin
var publisherIds = ["pub-1234567890123456"]
consent.requestConsentInformation(publisherIds)
In case of success the plugin emits the signal consent_info_updated
. Failure to request the consent information makes the plugin emit the signal failed_to_update_consent_information
.
enum CONSENT_STATUS {
UNKNOWN,
NON_PERSONALIZED,
PERSONALIZED
}
func consent_info_updated(consent_status):
match consent_status:
CONSENT_STATUS.UNKNOWN:
# Obtain user consent by showing a form
obtain_consent()
CONSENT_STATUS.NON_PERSONALIZED:
#configure AdMob implementation for non personalized apps
configure_admob_non_personalized()
CONSENT_STATUS.PERSONALIZED:
#configure AdMob implementation for personalized apps
configure_admob_personalized()
func failed_to_update_consent_information(error_description):
print(error_description)
To display the consent form you need to build, load and show the form in that order.
Building the form offers four options that are explained in the snippet below. Do not show the form unless it has been loaded successfully as indicated by the signal consent_form_loaded
.
func obtain_consent():
# Replace this string value with your own privacy policy url
var privacy_url = "https://www.yourcompan.com/your-privacy-policy/"
# Add the choice to select personalized ads to the form
var with_personalized_ads_option = true
# Add the choice to select non personalized ads to the form
var with_non_personalized_ads_option = true
# Add the choice to pay for an ad free version, handled in consent_form_closed
var with_ad_free_option = true
consent.buildConsentForm(privacy_url, with_personalized_ads_option , with_non_personalized_ads_option , ad_free_option)
consent.loadConsentForm()
func consent_form_loaded():
consent.showConsentForm()
func consent_form_opened():
pass
func consent_form_closed(consent_status, user_prefers_ad_free):
# Handle consent_status: UNKNOWN = 0 NON_PERSONALIZED = 1 PERSONALIZED = 2
# and/or the user's choice to pay for an ad free version
func consent_form_error(error_description):
print(error_description)
Remember you are not done yet! You still need to send the users decision regarding consent to AdMob. How you do this depends on how you implement AdMob.
The Plugin can be debugged by using the Android Debug Bridge and the tag filter ConsentPlugin
.