How to read consent choices in unity in C#

183 views
Skip to first unread message

Romain Bitard

unread,
Jan 11, 2024, 2:49:15 AMJan 11
to Google Mobile Ads SDK Developers
it says how to read consent choices from android/ios. How can we do that from C# with unity ? Is there a bridge or some classes we can use ?

"

Consent is not represented by a single bit, but rather a set of purposes and vendors as defined in the IAB TCF specification. See Consent Policies: Personalized & Non-Personalized Ads for criteria for Google Ads personalization.

See how to read consent choices (Android | iOS) for information on reading consent choices programmatically. The IAB also provides a web tool where you can manually decode the TC String.

"


Mobile Ads SDK Forum Advisor

unread,
Jan 11, 2024, 3:51:14 AMJan 11
to bitard...@gmail.com, google-adm...@googlegroups.com

Hi,

Thank you for contacting the Mobile Ads SDK Support team.

I will check with our team regarding your query and one of my team members will reach out to you once we have an update on this. Meanwhile, your patience is highly appreciated.

This message is in relation to case "ref:!00D1U01174p.!5004Q02rW1aI:ref"

Thanks,
 
Google Logo Mobile Ads SDK Team


Mobile Ads SDK Forum Advisor

unread,
Jan 11, 2024, 7:59:40 PMJan 11
to google-adm...@googlegroups.com, bitard...@gmail.com

Hi Romain,

You are correct that this is possible. `ApplicationPreferences` wraps around the apis used by Android and iOS.Here is some sample code to help you out.

 

  // Example value: "1111111111"
  string purposeConsents = ApplicationPreferences.GetString("IABTCF_PurposeConsents");
  // Purposes are zero-indexed. Index 0 contains information about Purpose 1.
  if (!string.IsNullOrEmpty(purposeConsents))
  {
    char purposeOneString = purposeConsents[0];
    boolean hasConsentForPurposeOne = purposeOneString == '1';
  }
 

 

Hope this helps,

Nick



ref:!00D1U01174p.!5004Q02rW1aI:ref

Romain Bitard

unread,
Jan 12, 2024, 8:50:22 AMJan 12
to Mobile Ads SDK Forum Advisor, google-adm...@googlegroups.com
Hello, Thank you for your response. ApplicationPreferences only have setters not getters. In which version of unity admob sdk is it available ?
image.png


Romain Bitard

unread,
Jan 12, 2024, 3:41:17 PMJan 12
to Google Mobile Ads SDK Developers
I tried to upgrade admob sdk but it seems to be located elsewhere, do you know what has to be done to get access to GetString method ?

Mobile Ads SDK Forum Advisor

unread,
Jan 16, 2024, 12:17:37 PMJan 16
to bitard...@gmail.com, google-adm...@googlegroups.com
Hi Romain,


This change is available now on GitHub and will be distributed with the next release.

Romain Bitard

unread,
Jan 16, 2024, 12:23:58 PMJan 16
to Mobile Ads SDK Forum Advisor, google-adm...@googlegroups.com
Thanks for the reply, that's what I saw too

Peter Gambell

unread,
Jan 16, 2024, 6:56:04 PMJan 16
to Google Mobile Ads SDK Developers
Hi Mobile Ads SDK team,

Will the next release of the Google Mobile Ads Unity plugin be soon? I'm keen to update to get this change to the ApplicationPreferences.

Mobile Ads SDK Forum Advisor

unread,
Jan 16, 2024, 7:31:09 PMJan 16
to peter....@gmail.com, google-adm...@googlegroups.com
Hi Peter,


I do not have an exact release date, but we are at work for our next release and hope to deliver it soon.

Thanks,

Nathan McKean

unread,
Jul 14, 2024, 9:32:53 PM (yesterday) Jul 14
to Google Mobile Ads SDK Developers
Can you confirm if ApplicationPreferences.GetString("IABTCF_PUrposeConsents"); is now supposed to be returning a value for Unity in C# because I keep getting a null response and would prefer to know if it is fruitless trying to fix my problem. (I am querying from the Unity Editor on a PC to test the implementation).

Mobile Ads SDK Forum Advisor

unread,
1:43 PM (8 hours ago) 1:43 PM
to nathan...@gmail.com, google-adm...@googlegroups.com
Hi Nathan,

I can confirm this issue was fixed in version 9.0.0 of the Google mobile ads SDK for Unity.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02rW1aI:ref" (ADR-00218729)

Thanks,
 
Google Logo
Nicholas Ventimiglia
Mobile Ads SDK Team


Reply all
Reply to author
Forward
0 new messages