Just realized you can check the consent result with plain lua code, no need for internal plugin access
local canShowPersonalizedAds = function()
local function hasAttribute(input, index)
if (input == nil) then return false end
return #input >= index and string.sub(input, index, index) == "1"
end
local function hasConsentFor(indexes, purposeConsent, hasVendorConsent)
for i = 1, #indexes do
if not hasAttribute(purposeConsent, indexes[i]) then
printl("hasConsent denied for purpose #" .. indexes[i] )
return false
end
end
return hasVendorConsent
end
local function hasConsentOrLegitimateInterestFor(indexes, purposeConsent, purposeLI, hasVendorConsent, hasVendorLI)
for i = 1, #indexes do
local purposeAndVendorLI = hasAttribute(purposeLI, indexes[i]) and hasVendorLI
local purposeConsentAndVendorConsent = hasAttribute(purposeConsent, indexes[i]) and hasVendorConsent
local isOk = purposeAndVendorLI or purposeConsentAndVendorConsent
if not isOk then
printl("hasConsentOrLegitimateInterestFor: denied for #" .. indexes[i])
return false
end
end
return true
end
local purposeConsent = system.getPreference( "app", "IABTCF_PurposeConsents", "string")
local vendorConsent = system.getPreference( "app", "IABTCF_VendorConsents","string")
local vendorLI = system.getPreference( "app", "IABTCF_VendorLegitimateInterests","string")
local purposeLI = system.getPreference( "app", "IABTCF_PurposeLegitimateInterests","string")
local googleId = 755
local hasGoogleVendorConsent = hasAttribute(vendorConsent, googleId)
local hasGoogleVendorLI = hasAttribute(vendorLI, googleId)
local hasConsent1 = hasConsentFor({1, 3, 4}, purposeConsent, hasGoogleVendorConsent)
local hasConsent2 = hasConsentOrLegitimateInterestFor({2, 7, 9, 10}, purposeConsent, purposeLI, hasGoogleVendorConsent, hasGoogleVendorLI)
return hasConsent1 and hasConsent2
end
If anyone finds a flaw feel free to comment.
Still the weird behavior when you change the date on the device, though, which looks more like a bug than intentional action by Admob