Android GDPR同意书错误:请求不在EEA或未知

时间:2018-06-01 18:58:06

标签: android

我正在尝试设置GDPR的同意书,但表单给出了错误:请求不在EEA或未知。我如何欺骗我在EEA的位置,以便我可以测试表格?我假设ConsentInformation类必须以某种方式获得我的GPS坐标,即使我已经尝试在手机和模拟器上运行它(两者的结果相同)。这是我的代码(与文档相同):

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();
}

2 个答案:

答案 0 :(得分:5)

谷歌在https://developers.google.com/admob/android/eu-consent下根据"测试"他们有关于如何测试欧洲经济区以外用户的说明。

希望这有帮助!

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

编辑:您还必须将您的设备添加为测试设备才能使其正常工作。初始化同意库后,您的设备的测试ID将显示在Logcat中。

答案 1 :(得分:1)

在模拟器中运行时,您可以使用“扩展控件”将您想要的任何坐标发送到手机。启动模拟器,单击“...”图标打开控件,然后选择“位置”并输入您想要的坐标 - 并单击“发送”。例如,经度0,纬度51.5在伦敦;经度48.9,纬度2.4在巴黎。 select