我正在尝试通过使用 Google 提供的新 Consent SDK 将GDPR 同意 dialog
添加到我的应用程序中,(我不住在欧盟)但是当我运行它时,我不能这是我的代码,对话框不会打开,我尝试使用 VPN 但仍然没有出现相同的对话框
/*GDRP*/
ConsentInformation consentInformation = ConsentInformation.getInstance(this);
String[] publisherIds = {"pub-xxxxx...."};
consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
@Override
public void onConsentInfoUpdated(ConsentStatus consentStatus) {
}
@Override
public void onFailedToUpdateConsentInfo(String errorDescription) {
}
});
URL privacyUrl = null;
try {
// TODO: Replace with your app's privacy policy URL.
privacyUrl = new URL("URL");
} catch (MalformedURLException e) {
e.printStackTrace();
// Handle error.
}
form = new ConsentForm.Builder(this, privacyUrl)
.withListener(new ConsentFormListener() {
@Override
public void onConsentFormLoaded(){
showForm();
}
@Override
public void onConsentFormOpened() {
}
@Override
public void onConsentFormClosed(
ConsentStatus consentStatus, Boolean userPrefersAdFree) {
}
@Override
public void onConsentFormError(String errorDescription) {
}
})
.withPersonalizedAdsOption()
.withNonPersonalizedAdsOption()
.withAdFreeOption()
.build();
form.load();
private void showForm() {
form.show();
}