Android, UMP always returns "OBTAINED" even if the user did not consent or if the user dismissed the form. So it's very hard to do anything with it. I want to know if the user did not consent, and in that case close the app. And then next time the app is opened the form should be shown immediately. However another problem is that when user selects things in the form and approves the consent, next time when the form is opened again the settings are reset (like if the form was never saved). Another problem is that it's almost impossible that the user has selected correct things to get ads and in most cases the user would get a free app without any ads (since the OBTAINED status does not tell if the user consented or not). Also I cannot get what the user selected (do I really need to look in sharedpreferences to get that info? Overall, this UMP seems to work very strange, or maybe I have implemented it wrong? Maybe there will be released any improvement to it soon? Using implementation 'com.google.android.ump:user-messaging-platform:2.1.0'
Also it seems if user has already given consent, and Admob settings is changed from personal to non-personal ads for my app, then user will still get the personal ads.
This is the code:
ConsentRequestParameters params = new ConsentRequestParameters
.Builder()
.setTagForUnderAgeOfConsent(false)
.build();
ConsentInformation consentInformation;
consentInformation = UserMessagingPlatform.getConsentInformation(this.getApplicationContext());
consentInformation.requestConsentInfoUpdate(
(Activity) 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()) {
// Loads a consent form. Must be called on the main thread.
UserMessagingPlatform.loadConsentForm(
MyActivity.this.getApplicationContext(),
new UserMessagingPlatform.OnConsentFormLoadSuccessListener() {
@Override
public void onConsentFormLoadSuccess(ConsentForm consentForm) {
consentForm.show(
(Activity) MyActivity.this,
new ConsentForm.OnConsentFormDismissedListener() {
@Override
public void onConsentFormDismissed(@Nullable FormError formError) {
// TODO: Always getting "OBTAINED" even if user dismissed form or selected to not consent.
// User did not consent so consentStatus is still REQUIRED
if (consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.REQUIRED) {
MyActivity.this.finish();
}
}
});
}
},
new UserMessagingPlatform.OnConsentFormLoadFailureListener() {
@Override
public void onConsentFormLoadFailure(FormError formError) {
// Handle Error.
}
}
);
} else {
// Handle error
}
}
},
new ConsentInformation.OnConsentInfoUpdateFailureListener() {
@Override
public void onConsentInfoUpdateFailure(FormError formError) {
// Handle the error.
}
});
I have tried to change the code in various ways but still have the same problems. So for now I have selected non-personal ads in Admob settings because UMP does not seem to work.
canRequestAds()
is set to true. From the docs it looks like canRequestAds() should only be true if the user consents to them, so it seems to be a bug in UMP. I am also using version 2.1.0 – Devaluate