Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android GDPR Consent Form Error: request is not in EEA or unknown

Tags:

android

I'm trying to setup the consent form for the GDPR, but the form gives me the error: request is not in EEA or unknown. How can I spoof my location to be in the EEA so I can test out the form? I assume the ConsentInformation class must be obtaining my GPS Coordinates somehow even though I've tried running this on a phone and on an emulator (same results for both). Here is my code (same as the documentation):

public class MainActivity extends AppCompatActivity {
ConsentForm form;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Timber.d(" *** Main Activity *** ");
    getConsent();
    showConsentForm();
}

public void getConsent() {
    Timber.d ("Attempting to get consent");
    ConsentInformation consentInformation = ConsentInformation.getInstance(this);
    String[] publisherIds = {"pub-2153652996366584"};
    consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
        @Override
        public void onConsentInfoUpdated(ConsentStatus consentStatus) {
            // User's consent status successfully updated.
        }

        @Override
        public void onFailedToUpdateConsentInfo(String errorDescription) {
            // User's consent status failed to update.
        }
    });
}

public void showConsentForm() {
    Timber.d ("Building consent form");
    URL privacyUrl = null;
    try {
        privacyUrl = new URL("https://www.your.com/privacyurl");
    } catch (MalformedURLException e) {
        Timber.e(e.getMessage());
    }
    form = new ConsentForm.Builder(this, privacyUrl)
            .withListener(new ConsentFormListener() {
                @Override
                public void onConsentFormLoaded() {
                    Timber.d("Consent form loaded successfully.");
                }

                @Override
                public void onConsentFormOpened() {
                    Timber.d("Consent form was displayed.");
                }

                @Override
                public void onConsentFormClosed(
                        ConsentStatus consentStatus, Boolean userPrefersAdFree) {
                    Timber.d("Consent form was closed.");
                }

                @Override
                public void onConsentFormError(String errorDescription) {
                    Timber.d("Consent form error:" + errorDescription);
                }
            })
            .withPersonalizedAdsOption()
            .withNonPersonalizedAdsOption()
            .withAdFreeOption()
            .build();
}

public void onConsentLoadClick(View view) {
    Timber.d("Loading the Consent Form");
    form.load();
}

public void onConsentShowClick(View view) {
    Timber.d("Showing the consent form");
    form.show();
}
like image 711
Jay Avatar asked Jun 01 '18 18:06

Jay


2 Answers

According to Google on https://developers.google.com/admob/android/eu-consent under the "Testing" section they have instructions on how to test for users outside of the EEA.

Hope this helps!

// Geography appears as in EEA for test devices.
ConsentInformation.getInstance(context).
consentInformation.addTestDevice("XXXXXXXXXXXXXXXXXXXXX");
consentInformation.setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_EEA);

EDIT: You must also add your device as a test device in order for this to work. Your device's test ID will be shown in the Logcat once you initialize the consent library.

like image 173
Vince Avatar answered Nov 15 '22 10:11

Vince


When running in an emulator, you can use "Extended Controls" to send any coordinates you wish to the phone. Start the emulator, click the "..." icon to open the controls, then select "Location" and enter coordinates you wish - and click "Send". For example, longitude 0, latitude 51.5 is in London; longitude 48.9, latitude 2.4 is in Paris. select

like image 41
Aleks G Avatar answered Nov 15 '22 09:11

Aleks G