User Messaging Platform (UMP) displays test dialog always even with no dialog published

362 views Asked by At

I'm trying to implement UMP dialog on apps with ADMOB:

Here is all the documentation about UMP: https://developers.google.com/admob/android/privacy?hl=en

And here is some good info about how it works: https://support.google.com/admob/answer/13554116 https://support.google.com/admob/answer/10113207

I'm doing exactly what documentation says, but the problem is that it is displaying a TEST UMP dialog always, even if the app doesn't have a dialog published in admob.

I tested it even signing the APK with the production certificate and updating the google play version of the app installing the APK update manually from a file in my device. Even doing that, a test dialog is being displayed, so I can't publish in production, because in theory a test dialog will be displayed to everyone when updates the app.

Is a reasonable explanation about this anywhere? I can't find it. I followed all the steps of the documentation. Can someone tell me what is wrong?

This is the test dialog being displayed:

enter image description here

This is the documentation source code I used in the app:

class MainActivity : AppCompatActivity() {
  private lateinit var consentInformation: ConsentInformation
  // Use an atomic boolean to initialize the Google Mobile Ads SDK and load ads once.
  private var isMobileAdsInitializeCalled = AtomicBoolean(false)
  
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    // Set tag for under age of consent. false means users are not under age
    // of consent.
    val params = ConsentRequestParameters
        .Builder()
        .setTagForUnderAgeOfConsent(false)
        .build()

    consentInformation = UserMessagingPlatform.getConsentInformation(this)
    consentInformation.requestConsentInfoUpdate(
        this,
        params,
        ConsentInformation.OnConsentInfoUpdateSuccessListener {
          UserMessagingPlatform.loadAndShowConsentFormIfRequired(
            this@MainActivity,
            ConsentForm.OnConsentFormDismissedListener {
              loadAndShowError ->
              // Consent gathering failed.
              Log.w(TAG, String.format("%s: %s",
                  loadAndShowError.errorCode(),
                  loadAndShowError.message()))

              // Consent has been gathered.
              if (consentInformation.canRequestAds) {
                initializeMobileAdsSdk()
              }
            }
          )
        },
        ConsentInformation.OnConsentInfoUpdateFailureListener {
          requestConsentError ->
          // Consent gathering failed.
          Log.w(TAG, String.format("%s: %s",
              requestConsentError.errorCode(),
              requestConsentError.message()))
        })
    
    // Check if you can initialize the Google Mobile Ads SDK in parallel
    // while checking for new consent information. Consent obtained in
    // the previous session can be used to request ads.
    if (consentInformation.canRequestAds) {
      initializeMobileAdsSdk()
    }
  }
  
  private fun initializeMobileAdsSdk() {
    if (isMobileAdsInitializeCalled.get()) {
      return
    }
    isMobileAdsInitializeCalled.set(true)

    // Initialize the Google Mobile Ads SDK.
    MobileAds.initialize(this)

    // TODO: Request an ad.
    // InterstitialAd.load(...)
  }
}
1

There are 1 answers

1
NullPointerException On BEST ANSWER

Finally the issue was that I had a bug in the automation of the replacement of the appid in the manifest.

If the appid is the test appid, it will display the Publisher Test Ads dialog, always, even with the dialog not created in admob.

I hope this will help someone sometime.