Reputation: 3062
Sharing following code, how am I calling for CMP dialog.
fun initDebugConsent(deviceId: String, onConsentResponse: OnConsentResponse) {
this.onConsentResponse = onConsentResponse
val debugSettings = ConsentDebugSettings.Builder(activity)
.setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
.addTestDeviceHashedId(deviceId)
.build()
val params = ConsentRequestParameters.Builder().setConsentDebugSettings(debugSettings).build()
requestConsentInfo(params)
}
private fun requestConsentInfo(params: ConsentRequestParameters) {
consentInformation.requestConsentInfoUpdate(activity, params, {
if (consentInformation.isConsentFormAvailable && consentInformation.consentStatus == ConsentInformation.ConsentStatus.REQUIRED) {
Log.d("ConsentManager", "initDebugConsent: Available & Required")
loadForm()
} else {
Log.d("ConsentManager", "initDebugConsent: Neither Available or Required")
onConsentResponse?.onResponse()
}
}, { error ->
Log.e("ConsentManager", "initDebugConsent: $error")
onConsentResponse?.onResponse(error.message)
})
}
Note: It do show first time, but after consent I have to wait a lot for again testing.
Upvotes: 1
Views: 293
Reputation: 3062
I got by resetting consentInformation
object only in debug
mode, as it is recommended by google team.
Caution: This method is intended to be used for testing purposes only. You shouldn't call reset() in production code.
consentInformation.reset()
Upvotes: 0