Window not showing - Obtaining Consent with the User Messaging Platform (Kotlin)

Viewed 261

I'm trying to implement UE consent that lets the user select if he wants personalized ads in Android, using Admob. I'm doing this with "Funding choices", with the user messaging platform.

I have complied with all conditions of the documentation. Nothing works.

class MainActivity : AppCompatActivity() {
lateinit var bindingClass : ActivityMainBinding

lateinit var consentInformation : ConsentInformation
lateinit var consentForm : ConsentForm


override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    bindingClass = ActivityMainBinding.inflate(layoutInflater)
    setContentView(bindingClass.root)

    val debugSettings = ConsentDebugSettings.Builder(this)
            .setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
            .build()

    val params = ConsentRequestParameters.Builder()
            .setTagForUnderAgeOfConsent(false)
            .setConsentDebugSettings(debugSettings)
            .build()

    consentInformation = UserMessagingPlatform.getConsentInformation(this)
    consentInformation.requestConsentInfoUpdate(
            this,
            params,
            {
                if (consentInformation.isConsentFormAvailable()) {
                    loadForm();
                }
            }
    ) {
        // Handle the error.
    }
}

fun loadForm(){
    UserMessagingPlatform.loadConsentForm(
            this,
            { consentForm ->
                this@MainActivity.consentForm = consentForm
                if (consentInformation.consentStatus == ConsentInformation.ConsentStatus.REQUIRED) {
                    consentForm.show(
                            this@MainActivity
                    ) { // Handle dismissal by reloading form.
                        loadForm()
                    }
                }
            }
    ) {
        /// Handle Error.
    }
}
}
0 Answers
Related