Skip to content
Draft
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Changelog

### v2.2.0 (TBD)

+ Added debug geography override support: `SetDebugSettings()` method, `ConsentDebugSettings` class and `ConsentDebugGeography` enum
+ Bumped `com.appodeal.mediation` dependency to v4.4.0

### v2.1.0 (June 23, 2026)

+ Added Privacy Options Form support: `ShowPrivacyOptionsForm()` method and `PrivacyOptionsStatus` property
Expand Down
16 changes: 16 additions & 0 deletions Runtime/Api/ConsentDebugSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// ReSharper disable CheckNamespace

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace AppodealStack.Cmp
{
[Serializable]
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
public sealed class ConsentDebugSettings
{
public ConsentDebugGeography Geography;
public List<string> TestDeviceIds;
}
}
11 changes: 11 additions & 0 deletions Runtime/Api/ConsentDebugSettings.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Runtime/Api/ConsentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace AppodealStack.Cmp
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public static class ConsentManager
{
private const string Version = "2.1.0";
private const string Version = "2.2.0";

private static readonly Lazy<IConsentManager> Lazy = new Lazy<IConsentManager>(() => new ConsentManagerClient());
public static IConsentManager Instance { get => Lazy.Value; }
Expand Down
14 changes: 14 additions & 0 deletions Runtime/Api/Enums/ConsentDebugGeography.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// ReSharper disable CheckNamespace

using System.Diagnostics.CodeAnalysis;

namespace AppodealStack.Cmp
{
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public enum ConsentDebugGeography
{
Eea,
RegulatedUsState,
Other,
}
}
11 changes: 11 additions & 0 deletions Runtime/Api/Enums/ConsentDebugGeography.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Runtime/Api/Interfaces/IConsentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public interface IConsentManager

void Load();
void LoadAndShowConsentFormIfRequired();
void SetDebugSettings(ConsentDebugSettings debugSettings);
void RequestConsentInfoUpdate(ConsentInfoParameters consentInfoParameters);
void ShowPrivacyOptionsForm();
void Revoke();
Expand Down
2 changes: 2 additions & 0 deletions Runtime/Api/Internal/ConsentManagerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ internal ConsentManagerClient()

public void LoadAndShowConsentFormIfRequired() => _consentManagerImpl?.LoadAndShowConsentFormIfRequired();

public void SetDebugSettings(ConsentDebugSettings debugSettings) => _consentManagerImpl?.SetDebugSettings(debugSettings);

public void RequestConsentInfoUpdate(ConsentInfoParameters consentInfoParameters) => _consentManagerImpl?.RequestConsentInfoUpdate(consentInfoParameters);

public void ShowPrivacyOptionsForm() => _consentManagerImpl?.ShowPrivacyOptionsForm();
Expand Down
25 changes: 25 additions & 0 deletions Runtime/Platforms/Android/AndroidCmpJavaHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,31 @@ public static AndroidJavaObject GetConsentInfoParametersJavaObject(ConsentInfoPa
);
}

public static AndroidJavaObject GetConsentDebugSettingsJavaObject(ConsentDebugSettings debugSettings)
{
if (debugSettings == null) return null;

var geography = new AndroidJavaClass("com.appodeal.consent.ConsentDebugGeography").GetStatic<AndroidJavaObject>(GetJavaGeographyName(debugSettings.Geography));
var testDeviceIds = new AndroidJavaObject("java.util.ArrayList");
foreach (string testDeviceId in (debugSettings.TestDeviceIds ?? Enumerable.Empty<string>()).Where(id => !String.IsNullOrEmpty(id)))
{
testDeviceIds.Call<bool>("add", testDeviceId);
}

return new AndroidJavaObject("com.appodeal.consent.ConsentDebugSettings", geography, testDeviceIds);
}

private static string GetJavaGeographyName(ConsentDebugGeography geography)
{
return geography switch
{
ConsentDebugGeography.Eea => "EEA",
ConsentDebugGeography.RegulatedUsState => "REGULATED_US_STATE",
ConsentDebugGeography.Other => "OTHER",
_ => throw new ArgumentOutOfRangeException(nameof(geography), geography, "value must be assignable to ConsentDebugGeography")
};
}

private static object GetJavaObject(object value)
{
return value switch
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Platforms/Android/AndroidConsentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public void LoadAndShowConsentFormIfRequired()
);
}

public void SetDebugSettings(ConsentDebugSettings debugSettings)
{
_consentManagerJavaClass?.CallStatic("setDebugSettings", AndroidCmpJavaHelper.GetConsentDebugSettingsJavaObject(debugSettings));
}

public void RequestConsentInfoUpdate(ConsentInfoParameters consentInfoParameters)
{
var paramsJavaObject = AndroidCmpJavaHelper.GetConsentInfoParametersJavaObject(consentInfoParameters);
Expand Down
2 changes: 2 additions & 0 deletions Runtime/Platforms/Dummy/DummyConsentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public event EventHandler<ConsentFormDismissedEventArgs> OnConsentFormDismissed

public void LoadAndShowConsentFormIfRequired() => DisplayUnsupportedPlatformWarning();

public void SetDebugSettings(ConsentDebugSettings debugSettings) => DisplayUnsupportedPlatformWarning();

public void RequestConsentInfoUpdate(ConsentInfoParameters consentInfoParameters) => DisplayUnsupportedPlatformWarning();

public void ShowPrivacyOptionsForm() => DisplayUnsupportedPlatformWarning();
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Platforms/Editor/EditorConsentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public void LoadAndShowConsentFormIfRequired()
editorConsentForm.Show();
}

public void SetDebugSettings(ConsentDebugSettings debugSettings)
{
Debug.Log("[Appodeal CMP] Debug settings are applied on Android and iOS only, the Editor ignores them");
}

public void RequestConsentInfoUpdate(ConsentInfoParameters consentInfoParameters)
{
_isConsentInfoRequested = true;
Expand Down
21 changes: 21 additions & 0 deletions Runtime/Platforms/iOS/IosConsentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// ReSharper disable CheckNamespace

using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Diagnostics.CodeAnalysis;
using AOT;
Expand Down Expand Up @@ -36,6 +37,23 @@ public void LoadAndShowConsentFormIfRequired()
CmpConsentManagerLoadAndShowConsentFormIfRequired(ConsentFormDismissed);
}

public void SetDebugSettings(ConsentDebugSettings debugSettings)
{
if (debugSettings == null)
{
CmpConsentManagerSetDebugSettings(-1, null);
return;
}

if (!Enum.IsDefined(typeof(ConsentDebugGeography), debugSettings.Geography))
{
throw new ArgumentOutOfRangeException(nameof(debugSettings.Geography), debugSettings.Geography, "value must be assignable to ConsentDebugGeography");
}

string testDeviceIds = debugSettings.TestDeviceIds == null ? "" : String.Join(",", debugSettings.TestDeviceIds.Where(id => !String.IsNullOrEmpty(id)));
CmpConsentManagerSetDebugSettings((int)debugSettings.Geography, testDeviceIds);
}

public void RequestConsentInfoUpdate(ConsentInfoParameters consentInfoParameters)
{
var paramsStruct = IosConsentInfoParameters.FromDtoClass(consentInfoParameters);
Expand Down Expand Up @@ -79,6 +97,9 @@ ConsentFormLoadSucceededCallback onConsentFormLoadSucceeded
[DllImport("__Internal", EntryPoint = "CMPUnityPluginConsentManagerShowPrivacyOptionsForm")]
private static extern void CmpConsentManagerShowPrivacyOptionsForm(ConsentFormDismissedCallback onConsentFormDismissed);

[DllImport("__Internal", EntryPoint = "CMPUnityPluginConsentManagerSetDebugSettings")]
private static extern void CmpConsentManagerSetDebugSettings(int geography, string testDeviceIds);

[DllImport("__Internal", EntryPoint = "CMPUnityPluginConsentManagerRequestConsentInfoUpdate")]
private static extern void CmpConsentManagerRequestConsentInfoUpdate(
IntPtr consentInfoParametersPtr,
Expand Down
14 changes: 14 additions & 0 deletions Runtime/Plugins/iOS/CmpConsentManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ void CMPUnityPluginConsentManagerLoadAndShowConsentFormIfRequired(ConsentFormDis
}];
}

void CMPUnityPluginConsentManagerSetDebugSettings(int geography, const char* testDeviceIds) {
APDConsentDebugGeography debugGeography;
switch (geography) {
case 0: debugGeography = APDConsentDebugGeographyEEA; break;
case 1: debugGeography = APDConsentDebugGeographyRegulatedUSState; break;
case 2: debugGeography = APDConsentDebugGeographyOther; break;
default: APDConsentManager.shared.debugSettings = nil; return;
}

NSString* joinedTestDeviceIds = testDeviceIds ? [NSString stringWithUTF8String:testDeviceIds] : @"";
NSArray<NSString*>* ids = joinedTestDeviceIds.length > 0 ? [joinedTestDeviceIds componentsSeparatedByString:@","] : @[];
APDConsentManager.shared.debugSettings = [[APDConsentDebugSettings alloc] initWithGeography:debugGeography testDeviceIds:ids];
}

void CMPUnityPluginConsentManagerRequestConsentInfoUpdate(CMPUnityPluginConsentInfoParameters consentInfoParameters,
ConsentInfoUpdateFailedCallback updateFailedCallback,
ConsentInfoUpdateSucceededCallback updateSucceededCallback) {
Expand Down
4 changes: 4 additions & 0 deletions Samples~/UsageSample/AppodealCmpDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public void RequestConsentInfoUpdate()

Debug.Log($"[Appodeal CMP] init params: {parameters.ToJsonString()}");

var debugSettings = new ConsentDebugSettings { Geography = ConsentDebugGeography.Eea };
Debug.Log($"[Appodeal CMP] SetDebugSettings() method called, geography: {debugSettings.Geography}");
ConsentManager.Instance.SetDebugSettings(debugSettings);

ConsentManager.Instance.RequestConsentInfoUpdate(parameters);
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "com.appodeal.cmp",
"version": "2.1.0",
"version": "2.2.0",
"displayName": "Appodeal CMP",
"description": "A Consent Management Platform (CMP) is a software that develops notices to inform users and capture their preferences with respect to the processing of their personal data.",
"unity": "2021.3",
"documentationUrl": "https://docs.appodeal.com/unity/data-protection/gdpr-and-ccpa",
"dependencies": {
"com.appodeal.mediation": "4.2.0"
"com.appodeal.mediation": "4.4.0"
},
"keywords": [
"CMP",
Expand Down