[Cocos2dx] How to implement consent dialog (GDPR) for EU user?

[Cocos2dx] How to implement consent dialog (GDPR) for EU user?


Hi all,

  • I’m newbie, I have 2 apps on google play store. Now, I want to add consent dialog for EU user to pass update new apk.

     + Here is consent dialog: https://developers.google.com/admob/android/eu-consent#google_rendered_consent_form
     + Here is google consent sdk: https://github.com/googleads/googleads-consent-sdk-android
  • I just google for guide of “EU consent for cocos2d, ex…” and I don’t see more info about it.

  • I used cocos2d v2.2.3 and Eclipse to export apk file.

How to start? Please share me step to do.

Thanks so much!


You have to inform the user about that you collect data.
what data you collect.
why you collect them.
with who you are sharing them with.
Your form should have an opt to accept and one to decline.

I just made a simple box using cocos2d::Sprite and cocos2d::Label, cocos2d::Menu.
Displaying the text and initializing my data related frameworks afterwards.

To determine if the user is an eu citizen i wrote a small function (android) (it doesnt identify the user as eu citizen if he doesnt use a phone and configured his device as non eu citizen)

    private int isEuCitizenZ = 0;         
    boolean isEuCitizen(){
    if(isEuCitizenZ != 0){
        return (isEuCitizenZ == 1);
    String euAry[] = {"BE", "EL", "LT", "PT", "BG", "ES", "LU", "RO", "CZ", "FR", "HU", "SI",
            "DK", "HR", "MT", "SK", "DE", "IT", "NL", "FI", "EE", "CY", "AT", "SE", "IE", "LV",
            "PL", "UK", "CH", "NO", "IS", "LI"};

    android.telephony.TelephonyManager tmgr = (android.telephony.TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    if(tmgr != null &&
            tmgr.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA){
        String country = tmgr.getNetworkCountryIso().toUpperCase();
            for(String euc : euAry){
                    isEuCitizenZ = 1;
                    return true;
            return false;
        android.os.LocaleList list = getContext().getResources().getConfiguration().getLocales();
        for(int i=0;i<list.size();i++){
            String country = list.get(i).getCountry().toUpperCase();
            for(String euc : euAry){
                    isEuCitizenZ = 1;
                    return true;
        String country = getContext().getResources().getConfiguration().locale.getCountry().toUpperCase();
        for(String euc : euAry){
                isEuCitizenZ = 1;
                return true;

    isEuCitizenZ = 2;
    return false;


I don’t collect any thing on my app.
May be 3rd party collect some info from user (I used Admod) -> check EU user -> show consent dialog -> save user consent -> show correct type of ads (personal, non personal,…) ?

I just find a nice library from gitHub (https://github.com/MFlisar/GDPRDialog). I’m checking this library.

Thanks for your comment!


I used Esclipe to export apk.
So, how to add this option below to esclipe ?

allprojects {
    repositories {
        maven {
            url "https://maven.google.com"


Add it in the build.gradle file!


@Wilem he asked for Eclipse :wink:

OT: You can exchange in gradle the maven { url : “http://maven.google.com” } part with just google(). This is much easier to remember. Your gradle build tool defined in the same file has to be at least version 3.


My english is not good, sorry for this.
I used cocos2d v.2.2.3
As you say: I need update to cocos2d v.3.x.x to have gradle build ?


With cocos 3.16 the default build chain will be with Android Studio (and gradle). It’s the preferred way for Android since end of 2016, because Google dropped Eclipse with ADK (Android Development Kit) support.

I don’t know how to include the Google maven repo for Eclipse, but I also don’t know the difficulties for the transition from cocos 2.2.3 to the latest cocos version (3.17). This can be a hard challenge, I guess.


I don’t have more time to upgrade cocos 3.x.x at this time, I need to implement consent dialog for EU user before google kill me. :joy:

For the bad case, I’ll remove ads admod for EU user and update new apk.

Who is using the cocos 2.x.x and have applied Consent Dialog for EU users, please give me a hint.

Thanks so much!


google wont care about if you care about GDPR or not.
Someone have to sue you to bring you in trouble.


If I only request non personal ads for EU user & show (doesn’t implement consent dialog) => pass GDPR?

  • I used consent sdk of google to check region of user (EU or Not) https://github.com/googleads/googleads-consent-sdk-android

  • If user is EU -> show my custom consent dialog to choose “personal ads” or “non-personal ads” -> save -> init right type of ads -> go game -> user can change again on option game.

  • If user is not EU -> init personal ads -> go game -> dont check anymore

=> It passed google check.:grinning:

Thanks for all help!


=> It passed google check

I think google doesn’t check for GDPR.
Problem can happen later if someone complain.


I hope my code work fine :smiley: