Skip to content

Instantly share code, notes, and snippets.

@Mirkoddd
Created March 8, 2022 11:44
Show Gist options
  • Save Mirkoddd/40c90bc9fb093f24d29acb8b595d33b5 to your computer and use it in GitHub Desktop.
Save Mirkoddd/40c90bc9fb093f24d29acb8b595d33b5 to your computer and use it in GitHub Desktop.
public boolean canShowAds(Context context){
prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
String purposeConsent = prefs.getString("IABTCF_PurposeConsents", "");
String vendorConsent = prefs.getString("IABTCF_VendorConsents","");
String vendorLI = prefs.getString("IABTCF_VendorLegitimateInterests","");
String purposeLI = prefs.getString("IABTCF_PurposeLegitimateInterests","");
int googleId = 755;
boolean hasGoogleVendorConsent = hasAttribute(vendorConsent, googleId);
boolean hasGoogleVendorLI = hasAttribute(vendorLI, googleId);
List<Integer> indexes = new ArrayList<>();
indexes.add(1);
List<Integer> indexesLI = new ArrayList<>();
indexesLI.add(2);
indexesLI.add(7);
indexesLI.add(9);
indexesLI.add(10);
return hasConsentFor(indexes, purposeConsent, hasGoogleVendorConsent)
&& hasConsentOrLegitimateInterestFor(indexesLI, purposeConsent, purposeLI, hasGoogleVendorConsent, hasGoogleVendorLI);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment