Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DIA-3629 introduce GCM for Android #43

Merged
merged 4 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ public static SpGdprConsent UnwrapSpGdprConsentAndroid(SpGdprConsentWrapperAndro
}
}

unwrapped.googleConsentMode = new SPGCMData(
wrappedGdpr.gcmStatus.ad_storage,
wrappedGdpr.gcmStatus.analytics_storage,
wrappedGdpr.gcmStatus.ad_user_data,
wrappedGdpr.gcmStatus.ad_personalization
);

return new SpGdprConsent(unwrapped);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace ConsentManagementProviderLib.Json
{
Expand All @@ -8,5 +9,7 @@ internal class SpGdprConsentWrapperAndroid
public string euconsent;
public Dictionary<string, object> tcData;
public Dictionary<string, Dictionary<string, object>> grants;
[JsonProperty("googleConsentMode")]
public GCMDataWrapper gcmStatus;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public string ToFullString()
sb.AppendLine($" {category}");
}

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

return sb.ToString();
}
Expand All @@ -70,8 +70,11 @@ public enum Status
}
public Status? adStorage, analyticsStorage, adUserData, adPersonalization;

public SPGCMData(Status? adStorage, Status? analyticsStorage,
Status? adUserData, Status? adPersonalization)
public SPGCMData(
Status? adStorage,
Status? analyticsStorage,
Status? adUserData,
Status? adPersonalization)
{
this.adStorage = adStorage;
this.analyticsStorage = analyticsStorage;
Expand All @@ -93,9 +96,17 @@ public class ConsentStatus
public object rejectedVendors;
public object rejectedCategories;

public ConsentStatus(bool? rejectedAny, bool? rejectedLI, bool? consentedAll,
bool? consentedToAny, bool? vendorListAdditions, bool? legalBasisChanges,
bool? hasConsentData, GranularStatus? granularStatus, object rejectedVendors, object rejectedCategories)
public ConsentStatus(
bool? rejectedAny,
bool? rejectedLI,
bool? consentedAll,
bool? consentedToAny,
bool? vendorListAdditions,
bool? legalBasisChanges,
bool? hasConsentData,
GranularStatus? granularStatus,
object rejectedVendors,
object rejectedCategories)
{
this.rejectedAny = rejectedAny;
this.rejectedLI = rejectedLI;
Expand All @@ -118,7 +129,13 @@ public class GranularStatus
public string? purposeLegInt;
public bool? previousOptInAll;
public bool? defaultConsent;
public GranularStatus(string? vendorConsent, string? vendorLegInt, string? purposeConsent, string? purposeLegInt, bool? previousOptInAll, bool? defaultConsent)
public GranularStatus(
string? vendorConsent,
string? vendorLegInt,
string? purposeConsent,
string? purposeLegInt,
bool? previousOptInAll,
bool? defaultConsent)
{
this.vendorConsent = vendorConsent;
this.vendorLegInt = vendorLegInt;
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ This getter is used to retrieve `SpConsents` data. After calling, it checks the
| |-- euconsent: String
| |-- acceptedCategories: List<String>
| |-- consentStatus: ConsentStatus
| |-- googleConsentMode: SPGCMData
| |-- adStorage: SPGCMData.Status?
| |-- analyticsStorage: SPGCMData.Status?
| |-- adUserData: SPGCMData.Status?
| |-- adPersonalization: SPGCMData.Status?
|-- ccpa?
|-- applies: bool
|-- consents: CcpaConsent
Expand Down Expand Up @@ -287,6 +292,14 @@ For vendors that are not part of the IAB, you can verify the user consented to t
consents.ccpa.consents.rejectedVendors.Contains("a_vendor_id");
```

## Google Consent Mode

[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).

### Update consent checks

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`.

## Adding or Removing custom consents

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