4

我尝试将 Google 同意与用户消息传递平台一起使用,以在 Android 应用同意表单中显示。我遵循此文档https://developers.google.com/admob/ump/android/quick-start

我收到此错误:

onConsentInfoUpdateFailure: Publisher misconfiguration: Failed to read publisher's account configuration; please check your configured app ID. Received app ID: `ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX`.

我的代码:

ConsentRequestParameters params;

    if (testingGDPR) {

        ConsentDebugSettings debugSettings = new ConsentDebugSettings.Builder(this)
                .setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
                .addTestDeviceHashedId(getString(R.string.ADMOB_REAL_DEVICE_HASH_ID_FOR_TESTING))
                .build();

        params = new ConsentRequestParameters.Builder().setConsentDebugSettings(debugSettings).build();
    } else {
        params = new ConsentRequestParameters.Builder().build();
    }

    consentInformation = UserMessagingPlatform.getConsentInformation(this);

    if (testingGDPR) {
        consentInformation.reset();
    }

    consentInformation.requestConsentInfoUpdate(
            this,
            params,
            new ConsentInformation.OnConsentInfoUpdateSuccessListener() {
                @Override
                public void onConsentInfoUpdateSuccess() {
                    
                    if (consentInformation.isConsentFormAvailable() && consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.REQUIRED) {
                        loadForm();
                    } else {
                        setupAds();
                    }
                }
            },
            new ConsentInformation.OnConsentInfoUpdateFailureListener() {
                @Override
                public void onConsentInfoUpdateFailure(FormError formError) {
                    Log.d("gdpr", "onConsentInfoUpdateFailure, code:" + formError.getErrorCode() + ", " + formError.getMessage());
                }
            });
4

1 回答 1

0

TestDeviceHashedId 与 Admob 设备 ID 不同。所以删除这一行:

.addTestDeviceHashedId(getString(R.string.ADMOB_REAL_DEVICE_HASH_ID_FOR_TESTING))

然后运行您的代码并检查日志。您应该使用的 TestDeviceHashedId 将出现。

于 2022-01-08T04:13:01.537 回答