【发布时间】:2021-10-02 02:54:08
【问题描述】:
按照本指南 https://developers.google.com/admob/ump/android/quick-start 我尝试将所有内容添加到我的应用程序中。
我做了什么:
- 将资金选择链接到 admob
- 将 ump 添加到 build.gradle
- 将应用 ID 添加到 android 清单中
- 在 admob 中为应用设置对话框并为应用激活它
然后我将此代码添加到我的应用程序中
ConsentRequestParameters params = new ConsentRequestParameters
.Builder()
.setTagForUnderAgeOfConsent(false)
.build();
consentInformation = UserMessagingPlatform.getConsentInformation(this);
consentInformation.requestConsentInfoUpdate(
this,
params,
new ConsentInformation.OnConsentInfoUpdateSuccessListener() {
@Override
public void onConsentInfoUpdateSuccess() {
// The consent information state was updated.
// You are now ready to check if a form is available.
if (consentInformation.isConsentFormAvailable()) {
loadForm();
}
else {
Context context = getApplicationContext();
CharSequence toastText = "No Form Available";
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, toastText, duration);
toast.show();
}
}
},
new ConsentInformation.OnConsentInfoUpdateFailureListener() {
@Override
public void onConsentInfoUpdateFailure(FormError formError) {
// Handle the error.
Context context = getApplicationContext();
CharSequence toastText = "Error";
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, toastText, duration);
toast.show();
}
});
和
public void loadForm() {
UserMessagingPlatform.loadConsentForm(
this,
new UserMessagingPlatform.OnConsentFormLoadSuccessListener() {
@Override
public void onConsentFormLoadSuccess(ConsentForm consentForm) {
MainActivity.this.consentForm = consentForm;
if(consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.REQUIRED) {
consentForm.show(
MainActivity.this,
new ConsentForm.OnConsentFormDismissedListener() {
@Override
public void onConsentFormDismissed(@Nullable FormError formError) {
// Handle dismissal by reloading form.
loadForm();
}
});
}
}
},
new UserMessagingPlatform.OnConsentFormLoadFailureListener() {
@Override
public void onConsentFormLoadFailure(FormError formError) {
// Handle the error
}
}
);
}
但是,我总是在 onConsentInfoUpdateFailure(FormError formError) 独立于在我的手机或虚拟设备上进行测试(顺便说一句我在欧洲)。
我错过了什么吗?
谢谢, 塞尔德里
【问题讨论】:
标签: java android gdprconsentform