Shin-NiL / Godot-Android-Admob-Plugin

Android AdMob plugin for Godot Game Engine 3.2 or higher
MIT License
543 stars 66 forks source link

Testing consent doesn't work #236

Open Momo90k opened 6 months ago

Momo90k commented 6 months ago

I'm outside the EU where GDPR is applicable. I check "Testing consent" but the form doesn't appear. The form is correctly configured and I'm using Godot version 3.5.3 and the latest version of the Admob plugin.

l2toplist commented 5 months ago

Hi, I just made a politics and privacy page in admob as you suggested. After that, Godot created a window with 3 buttons, Agree, No Personalization, Disagree. And I created 3 methods for them. For Agree example:

func Agree():
    # chage triger
    admob_node.is_personalized_set(true)
    # update info
    admob_node.request_consent_info_update()

func NotPersonalized():
    # chage triger
    admob_node.is_personalized_set(false)
    # update info
    admob_node.request_consent_info_update()
func Decline():
       print("User decline")

I also added error handlers (for debug) below


# Константы кодов ошибок
const ERROR_INTERNAL = 1
const ERROR_INTERNET = 2
const ERROR_INVALID_OPERATION = 3
const ERROR_TIME_OUT = 4

func _on_AdMob_consent_info_update_failure(error_code, error_message):
    match error_code:
        ERROR_INTERNAL:
            admob_print.bbcode_text = str("Internal Error: ", error_message)
        ERROR_INTERNET:
            admob_print.bbcode_text = str("Error internet-conectrion: ", error_message)
        ERROR_INVALID_OPERATION:
            admob_print.bbcode_text = str("Invalid operation ", error_message)
        ERROR_TIME_OUT:
            admob_print.bbcode_text = str("time-out: ", error_message)
        _:
            admob_print.bbcode_text = str("Unknown err: ", error_message)

# Объявляем константы для представления статусов согласия
const CONSENT_STATUS_NOT_REQUIRED = 1
const CONSENT_STATUS_OBTAINED = 3
const CONSENT_STATUS_REQUIRED = 2
const CONSENT_STATUS_UNKNOWN = 0

func _on_AdMob_consent_app_can_request_ad(consent_status):
    match consent_status:
        CONSENT_STATUS_NOT_REQUIRED:
            admob_print.bbcode_text = str("User consent is not required ")
            admob_node.load_rewarded_video()
        CONSENT_STATUS_OBTAINED:
            admob_print.bbcode_text = str("User consent has been obtained ")
            # on ad video
            admob_node.load_rewarded_video()
        CONSENT_STATUS_REQUIRED:
            admob_print.bbcode_text = str("User consent is required but not yet obtained. ")
        CONSENT_STATUS_UNKNOWN:
            admob_print.bbcode_text = str("The user's consent status is unknown. ")

Don't forget to connect the consent_info_update_failure and consent_app_can_request_ad signals to these methods from node Admob.

This is how my form appears, and when accepted, an advertising banner is loaded and displayed. But I launched it in test mode, P.S. Flags for ads_using_consent = true and testing_consent = true, by default in the admob node. I hope this information will be useful to you.