Yes, you can use the functions you wrote to interpret GDPR consent from SharedPreferences (IABTCF_PurposeConsents, IABTCF_VendorConsents, etc...). However, not all ad networks in mediation will automatically respect these choices. You’ll need to manually configure each ad network’s SDK to pass the GDPR consent data. For example:
I recommend you check the documentation for each ad network to find their specific GDPR configuration methods.
The UMP SDK stores US consent choices in SharedPreferences using the keys IABGPP_GppSID and IABGPP_HDR_GppString. Here’s how to interpret them:
Example:
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
val gppSid = prefs.getString("IABGPP_GppSID", "") ?: ""
val gppString = prefs.getString("IABGPP_HDR_GppString", "") ?: ""
If these keys are present, the user has made a choice. Pass this data to ad networks that support COPPA. For networks that don’t support it, enforce strict compliance globally.
If you enforce strict compliance, like using
ConsentRequestParameters.Builder().setTagForUnderAgeOfConsent(true)
it will apply globally, not just to GDPR or COPPA regions. This means:
P.S: If consent data is missing, assume no consent and serve non-personalized ads.