代码之家  ›  专栏  ›  技术社区  ›  Marwan Talal

Android应用程序|完全不显示同意书

  •  0
  • Marwan Talal  · 技术社区  · 3 年前

    最近我收到了这个通知。

    今年晚些时候,谷歌将要求所有向欧洲经济区和英国用户提供广告的发布商使用谷歌认证的同意管理平台(CMP)。您可以为此目的使用任何谷歌认证的CMP,包括谷歌自己的同意管理解决方案。如果您有兴趣使用谷歌的同意管理解决方案,请先设置您的GDPR消息并实施UMP SDK。了解更多

    我按照本页的说明进行了操作: https://developers.google.com/admob/android/privacy

    但表格没有显示。

    我正在使用最新的adMob SDK版本。我在AdMob上创建了“隐私和消息”消息。

    class MainActivity : ComponentActivity() {
    
    private lateinit var consentInformation: ConsentInformation
    private lateinit var consentForm: ConsentForm
    
    @OptIn(ExperimentalMaterial3Api::class)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    
    
        val debugSettings = ConsentDebugSettings.Builder(this)
            .setForceTesting(true)
            .setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_EEA)
            .build()
    
        val params = ConsentRequestParameters
            .Builder()
            .setConsentDebugSettings(debugSettings)
            .build()
    
        consentInformation = UserMessagingPlatform.getConsentInformation(this)
        consentInformation.requestConsentInfoUpdate(
            this,
            params,
            {
                if (consentInformation.isConsentFormAvailable) {
                    loadForm()
                }
            },
    
            {
                Toast.makeText(this,"${it.errorCode} && ${it.message}",Toast.LENGTH_LONG).show()
            }
    
        )
    
        setContent {
    }
    
    private fun loadForm() {
    
        // Loads a consent form. Must be called on the main thread.
        UserMessagingPlatform.loadConsentForm(
            this,
            {
                Toast.makeText(this,"0000000000",Toast.LENGTH_LONG).show()
                if (consentInformation.consentStatus == ConsentInformation.ConsentStatus.REQUIRED) {
                    Toast.makeText(this,"2222222",Toast.LENGTH_LONG).show()
                    consentForm.show(
                        this
                    ) {
                        if (consentInformation.consentStatus == ConsentInformation.ConsentStatus.OBTAINED) {
                            // App can start requesting ads.
                            Toast.makeText(
                                this,
                                "${it?.errorCode} && ${it?.message}",
                                Toast.LENGTH_LONG
                            ).show()
                        }
                        Toast.makeText(
                            this,
                            "${it?.errorCode} && ${it?.message}",
                            Toast.LENGTH_LONG
                        ).show()
                        // Handle dismissal by reloading form.
                        loadForm()
                    }
                }else{
                    Toast.makeText(this,"333333",Toast.LENGTH_LONG).show()
                }
            },
            {
                // Handle the error.
                Toast.makeText(this,"${it.errorCode} && ${it.message}",Toast.LENGTH_LONG).show()
            }
        )
    }}
    

    代码到达显示“222”的吐司,但表单没有出现!!

    0 回复  |  直到 3 年前