我正在尝试为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();
}
Run Code Online (Sandbox Code Playgroud)
根据Google在“测试”部分下的https://developers.google.com/admob/android/eu-consent所述,他们具有有关如何为EEA以外的用户进行测试的说明。
希望这可以帮助!
// Geography appears as in EEA for test devices.
ConsentInformation.getInstance(context).
consentInformation.addTestDevice("XXXXXXXXXXXXXXXXXXXXX");
consentInformation.setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_EEA);
Run Code Online (Sandbox Code Playgroud)
编辑:您还必须将您的设备添加为测试设备,以使其正常工作。初始化同意书库后,设备的测试ID将显示在Logcat中。
| 归档时间: |
|
| 查看次数: |
1052 次 |
| 最近记录: |