小编Mus*_*icX的帖子

窗口未显示 - 获得用户消息平台 (Kotlin) 的同意

我正在尝试使用 Admob 实现 UE 同意,让用户选择是否想要在 Android 中显示个性化广告。我正在通过用户消息平台的“资金选择”来做到这一点。

我已遵守文档中的所有条件。什么都不起作用。

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 …
Run Code Online (Sandbox Code Playgroud)

android admob kotlin android-studio

5
推荐指数
0
解决办法
418
查看次数

标签 统计

admob ×1

android ×1

android-studio ×1

kotlin ×1