我正在尝试为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();
}
发布于 2018-06-02 03:05:06
根据谷歌在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中。
发布于 2018-06-02 03:19:37
当在模拟器中运行时,您可以使用“扩展控件”将您希望的任何坐标发送到手机。启动仿真器,单击"...“图标打开控件,然后选择“位置”并输入您想要的坐标-并单击“发送”。例如,经度0,纬度51.5表示伦敦;经度48.9,纬度2.4表示巴黎。
https://stackoverflow.com/questions/50649577
复制相似问题