Skip to content

Commit 56c848a

Browse files
authored
Merge pull request #43 from SourcePointUSA/DIA-3629-introduce-gcm-for-android
DIA-3629 introduce `GCM` for `Android`
2 parents d98468f + 9b197b0 commit 56c848a

File tree

4 files changed

+48
-8
lines changed

4 files changed

+48
-8
lines changed

Assets/ConsentManagementProvider/Scripts/json/JsonUnwrapper.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ public static SpGdprConsent UnwrapSpGdprConsentAndroid(SpGdprConsentWrapperAndro
102102
}
103103
}
104104

105+
unwrapped.googleConsentMode = new SPGCMData(
106+
wrappedGdpr.gcmStatus.ad_storage,
107+
wrappedGdpr.gcmStatus.analytics_storage,
108+
wrappedGdpr.gcmStatus.ad_user_data,
109+
wrappedGdpr.gcmStatus.ad_personalization
110+
);
111+
105112
return new SpGdprConsent(unwrapped);
106113
}
107114

Assets/ConsentManagementProvider/Scripts/json/wrappers/android/SpGdprConsentWrapperAndroid.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using Newtonsoft.Json;
2+
using System.Collections.Generic;
23

34
namespace ConsentManagementProviderLib.Json
45
{
@@ -8,5 +9,7 @@ internal class SpGdprConsentWrapperAndroid
89
public string euconsent;
910
public Dictionary<string, object> tcData;
1011
public Dictionary<string, Dictionary<string, object>> grants;
12+
[JsonProperty("googleConsentMode")]
13+
public GCMDataWrapper gcmStatus;
1114
}
1215
}

Assets/ConsentManagementProvider/Scripts/model/common/GdprConsent.cs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public string ToFullString()
5555
sb.AppendLine($" {category}");
5656
}
5757

58-
sb.AppendLine($"adStorage: {googleConsentMode.adStorage.ToString()}, analyticsStorage: {googleConsentMode.analyticsStorage.ToString()}, adUserData: {googleConsentMode.adUserData.ToString()}, adPersonalization: {googleConsentMode.adPersonalization.ToString()}");
58+
sb.AppendLine($"adStorage: {googleConsentMode.adStorage}, analyticsStorage: {googleConsentMode.analyticsStorage}, adUserData: {googleConsentMode.adUserData}, adPersonalization: {googleConsentMode.adPersonalization}");
5959

6060
return sb.ToString();
6161
}
@@ -70,8 +70,11 @@ public enum Status
7070
}
7171
public Status? adStorage, analyticsStorage, adUserData, adPersonalization;
7272

73-
public SPGCMData(Status? adStorage, Status? analyticsStorage,
74-
Status? adUserData, Status? adPersonalization)
73+
public SPGCMData(
74+
Status? adStorage,
75+
Status? analyticsStorage,
76+
Status? adUserData,
77+
Status? adPersonalization)
7578
{
7679
this.adStorage = adStorage;
7780
this.analyticsStorage = analyticsStorage;
@@ -93,9 +96,17 @@ public class ConsentStatus
9396
public object rejectedVendors;
9497
public object rejectedCategories;
9598

96-
public ConsentStatus(bool? rejectedAny, bool? rejectedLI, bool? consentedAll,
97-
bool? consentedToAny, bool? vendorListAdditions, bool? legalBasisChanges,
98-
bool? hasConsentData, GranularStatus? granularStatus, object rejectedVendors, object rejectedCategories)
99+
public ConsentStatus(
100+
bool? rejectedAny,
101+
bool? rejectedLI,
102+
bool? consentedAll,
103+
bool? consentedToAny,
104+
bool? vendorListAdditions,
105+
bool? legalBasisChanges,
106+
bool? hasConsentData,
107+
GranularStatus? granularStatus,
108+
object rejectedVendors,
109+
object rejectedCategories)
99110
{
100111
this.rejectedAny = rejectedAny;
101112
this.rejectedLI = rejectedLI;
@@ -118,7 +129,13 @@ public class GranularStatus
118129
public string? purposeLegInt;
119130
public bool? previousOptInAll;
120131
public bool? defaultConsent;
121-
public GranularStatus(string? vendorConsent, string? vendorLegInt, string? purposeConsent, string? purposeLegInt, bool? previousOptInAll, bool? defaultConsent)
132+
public GranularStatus(
133+
string? vendorConsent,
134+
string? vendorLegInt,
135+
string? purposeConsent,
136+
string? purposeLegInt,
137+
bool? previousOptInAll,
138+
bool? defaultConsent)
122139
{
123140
this.vendorConsent = vendorConsent;
124141
this.vendorLegInt = vendorLegInt;

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ This getter is used to retrieve `SpConsents` data. After calling, it checks the
249249
| |-- euconsent: String
250250
| |-- acceptedCategories: List<String>
251251
| |-- consentStatus: ConsentStatus
252+
| |-- googleConsentMode: SPGCMData
253+
| |-- adStorage: SPGCMData.Status?
254+
| |-- analyticsStorage: SPGCMData.Status?
255+
| |-- adUserData: SPGCMData.Status?
256+
| |-- adPersonalization: SPGCMData.Status?
252257
|-- ccpa?
253258
|-- applies: bool
254259
|-- consents: CcpaConsent
@@ -287,6 +292,14 @@ For vendors that are not part of the IAB, you can verify the user consented to t
287292
consents.ccpa.consents.rejectedVendors.Contains("a_vendor_id");
288293
```
289294

295+
## Google Consent Mode
296+
297+
[Google Consent Mode 2.0](https://developers.google.com/tag-platform/security/concepts/consent-mode) ensures that Google vendors on your property comply with an end-user's consent choices for purposes (called consent checks) defined by Google. It is implemented via [Google Analytics for Firebase SDK](https://firebase.google.com/docs/analytics/unity/start).
298+
299+
### Update consent checks
300+
301+
Use Google's `setConsent` method to update the relevant consent checks when the appropriate purposes are consented to/rejected. Be advised that the `googleConsentMode` object in `GdprConsent` will only return values for Google consent checks that are mapped to a custom purpose within your vendor list. For all other Google consent checks, the response will be `null`.
302+
290303
## Adding or Removing custom consents
291304

292305
It's possible to programmatically consent the current user to a list of custom vendors, categories and legitimate interest categories with the method:

0 commit comments

Comments
 (0)