From 77cae92949585657662d81ae9941ad184ea98bb9 Mon Sep 17 00:00:00 2001 From: huehue-tangerine <11382080+huehue-tangerine@users.noreply.github.com> Date: Mon, 24 Jul 2023 07:05:25 -0300 Subject: [PATCH] Updated admob.gd - Updated "admob-lib/admob.gd" file with consent code. --- admob-lib/admob.gd | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/admob-lib/admob.gd b/admob-lib/admob.gd index fe9007c..4d804db 100644 --- a/admob-lib/admob.gd +++ b/admob-lib/admob.gd @@ -24,6 +24,11 @@ signal rewarded(currency, amount) signal rewarded_clicked signal rewarded_impression +signal consent_info_update_success +signal consent_info_update_failure(error_code, error_message) +signal consent_app_can_request_ad(consent_status) + + # properties export var is_real:bool setget is_real_set export var banner_on_top:bool = true @@ -37,6 +42,11 @@ export var child_directed:bool = false setget child_directed_set export var is_personalized:bool = true setget is_personalized_set export(String, "G", "PG", "T", "MA") var max_ad_content_rate = "G" setget max_ad_content_rate_set +# Testing consent flag +export var ads_using_consent:bool setget ads_using_consent +export var testing_consent:bool setget testing_consent_set + + # "private" properties var _admob_singleton = null var _is_interstitial_loaded:bool = false @@ -54,6 +64,12 @@ func is_real_set(new_val) -> void: # warning-ignore:return_value_discarded init() +func testing_consent_set(new_val) -> void: + testing_consent = new_val + +func ads_using_consent(new_val) -> void: + ads_using_consent = new_val + func child_directed_set(new_val) -> void: child_directed = new_val # warning-ignore:return_value_discarded @@ -116,6 +132,10 @@ func connect_signals() -> void: _admob_singleton.connect("on_rewarded_clicked", self, "_on_rewarded_clicked") _admob_singleton.connect("on_rewarded_impression", self, "_on_rewarded_impression") + _admob_singleton.connect("on_consent_info_update_success", self, "_on_consent_info_update_success") + _admob_singleton.connect("on_consent_info_update_failure", self, "_on_consent_info_update_failure") + _admob_singleton.connect("on_app_can_request_ads", self, "_on_app_can_request_ads") + # load func load_banner() -> void: @@ -191,6 +211,14 @@ func get_banner_dimension() -> Vector2: return Vector2(_admob_singleton.getBannerWidth(), _admob_singleton.getBannerHeight()) return Vector2() +func request_consent_info_update() -> void: + if _admob_singleton != null: + _admob_singleton.requestConsentInfoUpdate(testing_consent) + +func reset_consent() -> void: + if _admob_singleton != null: + _admob_singleton.resetConsentInformation() + # callbacks func _on_admob_ad_loaded() -> void: @@ -259,3 +287,12 @@ func _on_rewarded_clicked() -> void: func _on_rewarded_impression() -> void: emit_signal("rewarded_impression") + +func _on_consent_info_update_success() -> void: + emit_signal("consent_info_update_success") + +func _on_consent_info_update_failure(error_code:int, error_message:String) -> void: + emit_signal("consent_info_update_failure", error_code, error_message) + +func _on_app_can_request_ads(consent_status:int) -> void: + emit_signal("consent_app_can_request_ad", consent_status)