com.usercentrics.sdk.static 0.0.0-stage → 2.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Documentation/LICENSE +2 -0
- package/Documentation/LICENSE.meta +7 -0
- package/Documentation/README +169 -0
- package/Documentation/README.meta +7 -0
- package/Documentation.meta +8 -0
- package/Editor/ATTLocalizationMessageDrawer.cs +92 -0
- package/Editor/ATTLocalizationMessageDrawer.cs.meta +11 -0
- package/Editor/AssemblyInfo.cs +4 -0
- package/Editor/AssemblyInfo.cs.meta +11 -0
- package/Editor/Unity.UsercentricsEditor.asmdef +18 -0
- package/Editor/Unity.UsercentricsEditor.asmdef.meta +7 -0
- package/Editor/UsercentricsATTPostProcessor.cs +125 -0
- package/Editor/UsercentricsATTPostProcessor.cs.meta +11 -0
- package/Editor/UsercentricsAndroidPostBuild.cs +45 -0
- package/Editor/UsercentricsAndroidPostBuild.cs.meta +11 -0
- package/Editor/UsercentricsAndroidSdkCheck.cs +29 -0
- package/Editor/UsercentricsAndroidSdkCheck.cs.meta +11 -0
- package/Editor/UsercentricsDependencies.xml +18 -0
- package/Editor/UsercentricsDependencies.xml.meta +7 -0
- package/Editor/UsercentricsExternalDependencyManagerBuildCheck.cs +56 -0
- package/Editor/UsercentricsExternalDependencyManagerBuildCheck.cs.meta +11 -0
- package/Editor/UsercentricsExternalDependencyManagerCheck.cs +34 -0
- package/Editor/UsercentricsExternalDependencyManagerCheck.cs.meta +11 -0
- package/Editor/UsercentricsIOSBuildFixes.cs +171 -0
- package/Editor/UsercentricsIOSBuildFixes.cs.meta +11 -0
- package/Editor/UsercentricsPBXProjectExtensions.cs +281 -0
- package/Editor/UsercentricsPBXProjectExtensions.cs.meta +11 -0
- package/Editor/UsercentricsPodfilePatches.cs +116 -0
- package/Editor/UsercentricsPodfilePatches.cs.meta +11 -0
- package/Editor/UsercentricsSentryExcludePostBuild.cs +77 -0
- package/Editor/UsercentricsSentryExcludePostBuild.cs.meta +11 -0
- package/Editor/UsercentricsSentryGradleExclude.cs +189 -0
- package/Editor/UsercentricsSentryGradleExclude.cs.meta +11 -0
- package/Editor/UsercentricsWelcomeDialog.cs +76 -0
- package/Editor/UsercentricsWelcomeDialog.cs.meta +11 -0
- package/Editor.meta +8 -0
- package/Prefabs/ATTManager.prefab +47 -0
- package/Prefabs/ATTManager.prefab.meta +7 -0
- package/Prefabs/Usercentrics.prefab +74 -0
- package/Prefabs/Usercentrics.prefab.meta +7 -0
- package/Prefabs.meta +8 -0
- package/Scripts/AppTrackingTransparency/AppTrackingTransparencyManager.cs +59 -0
- package/Scripts/AppTrackingTransparency/AppTrackingTransparencyManager.cs.meta +11 -0
- package/Scripts/AppTrackingTransparency/Model/ATTLocalizationMessage.cs +15 -0
- package/Scripts/AppTrackingTransparency/Model/ATTLocalizationMessage.cs.meta +11 -0
- package/Scripts/AppTrackingTransparency/Model/AuthorizationStatus.cs +10 -0
- package/Scripts/AppTrackingTransparency/Model/AuthorizationStatus.cs.meta +11 -0
- package/Scripts/AppTrackingTransparency/Model/Language.cs +136 -0
- package/Scripts/AppTrackingTransparency/Model/Language.cs.meta +11 -0
- package/Scripts/AppTrackingTransparency/Model.meta +8 -0
- package/Scripts/AppTrackingTransparency.cs +60 -0
- package/Scripts/AppTrackingTransparency.cs.meta +11 -0
- package/Scripts/AppTrackingTransparency.meta +8 -0
- package/Scripts/Internal/AssemblyInfo.cs +3 -0
- package/Scripts/Internal/AssemblyInfo.cs.meta +11 -0
- package/Scripts/Internal/AutoInitialize.cs +42 -0
- package/Scripts/Internal/AutoInitialize.cs.meta +11 -0
- package/Scripts/Internal/BannerSettings.cs +165 -0
- package/Scripts/Internal/BannerSettings.cs.meta +11 -0
- package/Scripts/Internal/ConsentUpdateSubscriptionCoordinator.cs +42 -0
- package/Scripts/Internal/ConsentUpdateSubscriptionCoordinator.cs.meta +11 -0
- package/Scripts/Internal/Data.cs +960 -0
- package/Scripts/Internal/Data.cs.meta +11 -0
- package/Scripts/Internal/Errors.cs +22 -0
- package/Scripts/Internal/Errors.cs.meta +11 -0
- package/Scripts/Internal/FirstLayerStyleSettings.cs +248 -0
- package/Scripts/Internal/FirstLayerStyleSettings.cs.meta +11 -0
- package/Scripts/Internal/IUsercentrics.cs +45 -0
- package/Scripts/Internal/IUsercentrics.cs.meta +11 -0
- package/Scripts/Internal/InspectorLink.cs +27 -0
- package/Scripts/Internal/InspectorLink.cs.meta +11 -0
- package/Scripts/Internal/Singleton.cs +68 -0
- package/Scripts/Internal/Singleton.cs.meta +11 -0
- package/Scripts/Internal/StringParser.cs +41 -0
- package/Scripts/Internal/StringParser.cs.meta +11 -0
- package/Scripts/Internal/UCConstants.cs +13 -0
- package/Scripts/Internal/UCConstants.cs.meta +11 -0
- package/Scripts/Internal/UnityConsentModeAdapter.cs +78 -0
- package/Scripts/Internal/UnityConsentModeAdapter.cs.meta +11 -0
- package/Scripts/Internal/UsercentricsAndroid.cs +210 -0
- package/Scripts/Internal/UsercentricsAndroid.cs.meta +11 -0
- package/Scripts/Internal/UsercentricsIOS.cs +307 -0
- package/Scripts/Internal/UsercentricsIOS.cs.meta +11 -0
- package/Scripts/Internal.meta +8 -0
- package/Scripts/Unity.Usercentrics.asmdef +14 -0
- package/Scripts/Unity.Usercentrics.asmdef.meta +7 -0
- package/Scripts/Usercentrics.cs +1160 -0
- package/Scripts/Usercentrics.cs.meta +11 -0
- package/Scripts.meta +8 -0
- package/UsercentricsInstallGuard/Usercentrics.InstallGuard.Static.asmdef +16 -0
- package/UsercentricsInstallGuard/Usercentrics.InstallGuard.Static.asmdef.meta +7 -0
- package/UsercentricsInstallGuard/UsercentricsInstallGuard.cs +82 -0
- package/UsercentricsInstallGuard/UsercentricsInstallGuard.cs.meta +11 -0
- package/UsercentricsInstallGuard.meta +8 -0
- package/iOS/TrackingTransparencyManager.h +13 -0
- package/iOS/TrackingTransparencyManager.h.meta +27 -0
- package/iOS/TrackingTransparencyManager.mm +99 -0
- package/iOS/TrackingTransparencyManager.mm.meta +37 -0
- package/iOS/Usercentrics.mm +228 -0
- package/iOS/Usercentrics.mm.meta +37 -0
- package/iOS/UsercentricsATTManager.mm +21 -0
- package/iOS/UsercentricsATTManager.mm.meta +37 -0
- package/iOS.meta +8 -0
- package/link.xml +24 -0
- package/link.xml.meta +7 -0
- package/package.json +10 -4
- package/package.json.meta +7 -0
- package/README.md +0 -3
|
@@ -0,0 +1,1160 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEditor;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using UnityEngine.Events;
|
|
6
|
+
using System.ComponentModel;
|
|
7
|
+
|
|
8
|
+
namespace Unity.Usercentrics
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// Usercentrics Consent Management Platform (c) 2024.
|
|
12
|
+
/// It gives access to the singleton (Instance) and the whole API.
|
|
13
|
+
/// </summary>
|
|
14
|
+
public class Usercentrics : Singleton<Usercentrics>
|
|
15
|
+
{
|
|
16
|
+
#region INSPECTOR FIELDS
|
|
17
|
+
[Header("Enter either Settings ID or Ruleset ID")]
|
|
18
|
+
[SerializeField] public string SettingsID = "";
|
|
19
|
+
[SerializeField] public string RulesetID = "";
|
|
20
|
+
[SerializeField] public UsercentricsOptions Options = new UsercentricsOptions();
|
|
21
|
+
#if UNITY_EDITOR
|
|
22
|
+
[InspectorLink] [SerializeField] internal string ConfigurationDashboard = "https://account.usercentrics.eu";
|
|
23
|
+
[InspectorLink] [SerializeField] internal string Documentation = "https://usercentrics.com/docs/games/intro/";
|
|
24
|
+
#endif
|
|
25
|
+
#endregion
|
|
26
|
+
|
|
27
|
+
private readonly IUsercentricsPlatform UsercentricsPlatform =
|
|
28
|
+
#if UNITY_IOS
|
|
29
|
+
new UsercentricsIOS();
|
|
30
|
+
#elif UNITY_ANDROID
|
|
31
|
+
new UsercentricsAndroid();
|
|
32
|
+
#else
|
|
33
|
+
null;
|
|
34
|
+
#endif
|
|
35
|
+
|
|
36
|
+
private UnityAction<UsercentricsConsentUserResponse> onDismissCallback;
|
|
37
|
+
private UnityAction<UsercentricsReadyStatus> initializeCallback;
|
|
38
|
+
private UnityAction<string> initializeErrorCallback;
|
|
39
|
+
private UnityAction<TCFData> tcfDataCallback;
|
|
40
|
+
private List<UnityAction<UsercentricsUpdatedConsentEvent>> onConsentUpdatedCallbacks = new List<UnityAction<UsercentricsUpdatedConsentEvent>>();
|
|
41
|
+
private List<UnityAction<UsercentricsMediationEvent>> onConsentMediationCallbacks = new List<UnityAction<UsercentricsMediationEvent>>();
|
|
42
|
+
private List<UnityAction<GppSectionChangeEvent>> onGppSectionChangeCallbacks = new List<UnityAction<GppSectionChangeEvent>>();
|
|
43
|
+
|
|
44
|
+
private UnityAction<UsercentricsReadyStatus> restoreSessionSuccessCallback;
|
|
45
|
+
private UnityAction<string> restoreSessionErrorCallback;
|
|
46
|
+
|
|
47
|
+
private UnityAction<UsercentricsReadyStatus> clearSessionSuccessCallback;
|
|
48
|
+
private UnityAction<string> clearSessionErrorCallback;
|
|
49
|
+
|
|
50
|
+
private UnityAction<string> onLoginClickedCallback;
|
|
51
|
+
private UnityAction<string> onSubscribeClickedCallback;
|
|
52
|
+
|
|
53
|
+
private UnityAction notifyLoginSuccessCallback;
|
|
54
|
+
private UnityAction<string> notifyLoginErrorCallback;
|
|
55
|
+
private UnityAction notifySubscribeSuccessCallback;
|
|
56
|
+
private UnityAction<string> notifySubscribeErrorCallback;
|
|
57
|
+
private UnityAction notifySubscriptionLapsedSuccessCallback;
|
|
58
|
+
private UnityAction<string> notifySubscriptionLapsedErrorCallback;
|
|
59
|
+
|
|
60
|
+
private UnityAction changeLanguageSuccessCallback;
|
|
61
|
+
private UnityAction<string> changeLanguageErrorCallback;
|
|
62
|
+
|
|
63
|
+
private UnityAction<UsercentricsAgeSignalDecision> setAgeSignalSuccessCallback;
|
|
64
|
+
private UnityAction<string> setAgeSignalErrorCallback;
|
|
65
|
+
|
|
66
|
+
private UnityConsentModeAdapter unityConsentModeAdapter;
|
|
67
|
+
private readonly ConsentUpdateSubscriptionCoordinator consentUpdateSubscriptionCoordinator = new ConsentUpdateSubscriptionCoordinator();
|
|
68
|
+
|
|
69
|
+
#region USERCENTRICS API
|
|
70
|
+
/// <summary>
|
|
71
|
+
/// Get if Usercentrics was initialized or not.
|
|
72
|
+
/// </summary>
|
|
73
|
+
/// <returns>true if it was initialized, false otherwise.</returns>
|
|
74
|
+
public bool IsInitialized
|
|
75
|
+
{ get; private set; }
|
|
76
|
+
|
|
77
|
+
/// <summary>
|
|
78
|
+
/// Initialize Usercentrics obtaining latest online configuration and
|
|
79
|
+
/// local storage to enable consents management.
|
|
80
|
+
/// </summary>
|
|
81
|
+
/// <param name="initializeCallback">
|
|
82
|
+
/// Callback block that is invoked when the initialize process finishes.
|
|
83
|
+
/// It returns UsercentricsReadyStatus.
|
|
84
|
+
/// </param>
|
|
85
|
+
/// <param name="initializeErrorCallback">
|
|
86
|
+
/// Callback block that is invoked when the initialize process finishes
|
|
87
|
+
/// with an error.
|
|
88
|
+
/// It returns a non-localized string with information about the error.
|
|
89
|
+
/// </param>
|
|
90
|
+
public void Initialize(
|
|
91
|
+
UnityAction<UsercentricsReadyStatus> initializeCallback,
|
|
92
|
+
UnityAction<string> initializeErrorCallback
|
|
93
|
+
){
|
|
94
|
+
ensureSupportedPlatform();
|
|
95
|
+
logDebug("Initialize invoked");
|
|
96
|
+
|
|
97
|
+
this.initializeCallback = initializeCallback;
|
|
98
|
+
this.initializeErrorCallback = initializeErrorCallback;
|
|
99
|
+
|
|
100
|
+
var optionsInternal = UsercentricsOptionsInternal.CreateFrom(Options, SettingsID, RulesetID);
|
|
101
|
+
|
|
102
|
+
string optionsJson = JsonUtility.ToJson(optionsInternal);
|
|
103
|
+
|
|
104
|
+
this.IsInitialized = false;
|
|
105
|
+
UsercentricsPlatform?.Initialize(optionsJson);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private void Awake()
|
|
109
|
+
{
|
|
110
|
+
// Make instance persistent.
|
|
111
|
+
DontDestroyOnLoad(gameObject);
|
|
112
|
+
warnIfRenamed();
|
|
113
|
+
this.unityConsentModeAdapter = new UnityConsentModeAdapter(Options.UnityConsentMode, logDebug);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// The native SDK sends its callbacks to a GameObject whose name it chooses itself, so a renamed
|
|
117
|
+
// instance fails in the quietest possible way: the native SDK initializes and reports it is ready,
|
|
118
|
+
// no callback ever reaches C#, IsInitialized stays false, the banner never shows and nothing is
|
|
119
|
+
// logged anywhere. Say so instead of leaving the integrator to guess.
|
|
120
|
+
private void warnIfRenamed()
|
|
121
|
+
{
|
|
122
|
+
if (gameObject.name == UCConstants.GAME_OBJECT_NAME)
|
|
123
|
+
{
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
Debug.LogError("[USERCENTRICS] This GameObject is named '" + gameObject.name + "', but the native SDK " +
|
|
128
|
+
"delivers its callbacks to one named '" + UCConstants.GAME_OBJECT_NAME + "'. Initialization " +
|
|
129
|
+
"will appear to hang: the native SDK starts, nothing reaches C#, IsInitialized stays false " +
|
|
130
|
+
"and the banner never shows. Rename it back to '" + UCConstants.GAME_OBJECT_NAME + "'.");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/// <summary>
|
|
134
|
+
/// Get if current selected platform is supported by Usercentrics.
|
|
135
|
+
/// </summary>
|
|
136
|
+
/// <returns>true if it is supported, false otherwise.</returns>
|
|
137
|
+
public bool IsPlatformSupported()
|
|
138
|
+
{
|
|
139
|
+
return UsercentricsPlatform != null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/// <summary>
|
|
143
|
+
/// Show Usercentrics Banner's First Layer.
|
|
144
|
+
/// </summary>
|
|
145
|
+
/// <param name="onDismissCallback">
|
|
146
|
+
/// Callback block that is invoked when the user performs an action on the Banner.
|
|
147
|
+
/// </param>
|
|
148
|
+
public void ShowFirstLayer(UnityAction<UsercentricsConsentUserResponse> onDismissCallback)
|
|
149
|
+
{
|
|
150
|
+
ShowFirstLayer(bannerSettings: null, onDismissCallback: onDismissCallback);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/// <summary>
|
|
154
|
+
/// Show Usercentrics Banner's First Layer.
|
|
155
|
+
/// </summary>
|
|
156
|
+
/// <param name="bannerSettings"></param>
|
|
157
|
+
/// Sends the customization configuration for the banner
|
|
158
|
+
/// </param>
|
|
159
|
+
/// <param name="onDismissCallback">
|
|
160
|
+
/// Callback block that is invoked when the user performs an action on the Banner.
|
|
161
|
+
/// </param>
|
|
162
|
+
public void ShowFirstLayer(BannerSettings bannerSettings, UnityAction<UsercentricsConsentUserResponse> onDismissCallback)
|
|
163
|
+
{
|
|
164
|
+
ensureSupportedPlatform();
|
|
165
|
+
logDebug("ShowFirstLayer invoked");
|
|
166
|
+
ensureInitialized();
|
|
167
|
+
|
|
168
|
+
this.onDismissCallback = onDismissCallback;
|
|
169
|
+
|
|
170
|
+
var bannerSettingsWithOptions = BuildBannerSettingsWithOptions(bannerSettings);
|
|
171
|
+
var bannerSettingsJson = JsonUtility.ToJson(bannerSettingsWithOptions);
|
|
172
|
+
|
|
173
|
+
UsercentricsPlatform?.ShowFirstLayer(bannerSettingsJson);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/// <summary>
|
|
177
|
+
/// Show Usercentrics Banner's First Layer with Consent or Pay callbacks.
|
|
178
|
+
/// </summary>
|
|
179
|
+
/// <param name="onDismissCallback">
|
|
180
|
+
/// Callback block that is invoked when the user performs an action on the Banner.
|
|
181
|
+
/// </param>
|
|
182
|
+
/// <param name="onLoginClicked">
|
|
183
|
+
/// Callback block that is invoked when the user taps the Consent-or-Pay subscriber-login link.
|
|
184
|
+
/// The banner is not dismissed automatically.
|
|
185
|
+
/// </param>
|
|
186
|
+
/// <param name="onSubscribeClicked">
|
|
187
|
+
/// Callback block that is invoked when the user taps the Consent-or-Pay Reject & Subscribe button.
|
|
188
|
+
/// The banner is not dismissed automatically.
|
|
189
|
+
/// </param>
|
|
190
|
+
public void ShowFirstLayer(
|
|
191
|
+
UnityAction<UsercentricsConsentUserResponse> onDismissCallback,
|
|
192
|
+
UnityAction<string> onLoginClicked,
|
|
193
|
+
UnityAction<string> onSubscribeClicked
|
|
194
|
+
){
|
|
195
|
+
ShowFirstLayer(bannerSettings: null, onDismissCallback: onDismissCallback, onLoginClicked: onLoginClicked, onSubscribeClicked: onSubscribeClicked);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/// <summary>
|
|
199
|
+
/// Show Usercentrics Banner's First Layer with Consent or Pay callbacks.
|
|
200
|
+
/// </summary>
|
|
201
|
+
/// <param name="bannerSettings"></param>
|
|
202
|
+
/// Sends the customization configuration for the banner
|
|
203
|
+
/// </param>
|
|
204
|
+
/// <param name="onDismissCallback">
|
|
205
|
+
/// Callback block that is invoked when the user performs an action on the Banner.
|
|
206
|
+
/// </param>
|
|
207
|
+
/// <param name="onLoginClicked">
|
|
208
|
+
/// Callback block that is invoked when the user taps the Consent-or-Pay subscriber-login link.
|
|
209
|
+
/// The banner is not dismissed automatically.
|
|
210
|
+
/// </param>
|
|
211
|
+
/// <param name="onSubscribeClicked">
|
|
212
|
+
/// Callback block that is invoked when the user taps the Consent-or-Pay Reject & Subscribe button.
|
|
213
|
+
/// The banner is not dismissed automatically.
|
|
214
|
+
/// </param>
|
|
215
|
+
public void ShowFirstLayer(
|
|
216
|
+
BannerSettings bannerSettings,
|
|
217
|
+
UnityAction<UsercentricsConsentUserResponse> onDismissCallback,
|
|
218
|
+
UnityAction<string> onLoginClicked,
|
|
219
|
+
UnityAction<string> onSubscribeClicked
|
|
220
|
+
){
|
|
221
|
+
ensureSupportedPlatform();
|
|
222
|
+
logDebug("ShowFirstLayer invoked");
|
|
223
|
+
ensureInitialized();
|
|
224
|
+
|
|
225
|
+
this.onDismissCallback = onDismissCallback;
|
|
226
|
+
this.onLoginClickedCallback = onLoginClicked;
|
|
227
|
+
this.onSubscribeClickedCallback = onSubscribeClicked;
|
|
228
|
+
|
|
229
|
+
var bannerSettingsWithOptions = BuildBannerSettingsWithOptions(bannerSettings);
|
|
230
|
+
var bannerSettingsJson = JsonUtility.ToJson(bannerSettingsWithOptions);
|
|
231
|
+
|
|
232
|
+
UsercentricsPlatform?.ShowFirstLayer(bannerSettingsJson);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/// <summary>
|
|
236
|
+
/// Show Usercentrics Banner's First Layer.
|
|
237
|
+
/// </summary>
|
|
238
|
+
/// <param name="bannerSettings"></param>
|
|
239
|
+
/// Sends the customization configuration for the banner
|
|
240
|
+
/// </param>
|
|
241
|
+
/// <param name="onDismissCallback">
|
|
242
|
+
/// Callback block that is invoked when the user performs an action on the Banner.
|
|
243
|
+
/// </param>
|
|
244
|
+
public void ShowSecondLayer(BannerSettings bannerSettings, UnityAction<UsercentricsConsentUserResponse> onDismissCallback)
|
|
245
|
+
{
|
|
246
|
+
ensureSupportedPlatform();
|
|
247
|
+
logDebug("ShowSecondLayer invoked");
|
|
248
|
+
ensureInitialized();
|
|
249
|
+
|
|
250
|
+
this.onDismissCallback = onDismissCallback;
|
|
251
|
+
|
|
252
|
+
var bannerSettingsWithOptions = BuildBannerSettingsWithOptions(bannerSettings);
|
|
253
|
+
var bannerSettingsJson = JsonUtility.ToJson(bannerSettingsWithOptions);
|
|
254
|
+
|
|
255
|
+
UsercentricsPlatform?.ShowSecondLayer(bannerSettingsJson);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/// <summary>
|
|
259
|
+
/// Show Usercentrics Banner's Second Layer opened directly on the given tab.
|
|
260
|
+
/// A tab the layout does not have opens the default tab.
|
|
261
|
+
/// </summary>
|
|
262
|
+
/// <param name="bannerSettings">
|
|
263
|
+
/// Sends the customization configuration for the banner
|
|
264
|
+
/// </param>
|
|
265
|
+
/// <param name="tab">
|
|
266
|
+
/// Tab of the Second Layer to open.
|
|
267
|
+
/// </param>
|
|
268
|
+
/// <param name="onDismissCallback">
|
|
269
|
+
/// Callback block that is invoked when the user performs an action on the Banner.
|
|
270
|
+
/// </param>
|
|
271
|
+
public void ShowSecondLayer(BannerSettings bannerSettings, SecondLayerTab tab, UnityAction<UsercentricsConsentUserResponse> onDismissCallback)
|
|
272
|
+
{
|
|
273
|
+
ensureSupportedPlatform();
|
|
274
|
+
logDebug("ShowSecondLayer invoked with tab " + tab);
|
|
275
|
+
ensureInitialized();
|
|
276
|
+
|
|
277
|
+
this.onDismissCallback = onDismissCallback;
|
|
278
|
+
|
|
279
|
+
var bannerSettingsWithOptions = BuildBannerSettingsWithOptions(bannerSettings);
|
|
280
|
+
var bannerSettingsJson = JsonUtility.ToJson(bannerSettingsWithOptions);
|
|
281
|
+
|
|
282
|
+
UsercentricsPlatform?.ShowSecondLayer(bannerSettingsJson, tab.ToString().ToUpperInvariant());
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/// <summary>
|
|
286
|
+
/// Get the controller ID of the current session.
|
|
287
|
+
/// </summary>
|
|
288
|
+
/// <returns>the controller ID string</returns>
|
|
289
|
+
public string GetControllerId()
|
|
290
|
+
{
|
|
291
|
+
ensureSupportedPlatform();
|
|
292
|
+
logDebug("GetControllerID Invoked");
|
|
293
|
+
ensureInitialized();
|
|
294
|
+
return UsercentricsPlatform?.GetControllerID();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/// <summary>
|
|
298
|
+
/// Retrieve TCF Data
|
|
299
|
+
/// </summary>
|
|
300
|
+
/// <returns>all data related to TCF, in case the SDK is using a TCF framework configuration</returns>
|
|
301
|
+
public void GetTCFData(UnityAction<TCFData> callback)
|
|
302
|
+
{
|
|
303
|
+
ensureSupportedPlatform();
|
|
304
|
+
logDebug("GetTCFData invoked");
|
|
305
|
+
this.tcfDataCallback = callback;
|
|
306
|
+
UsercentricsPlatform?.GetTCFData();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/// <summary>
|
|
310
|
+
/// Get the CCPA Data
|
|
311
|
+
/// </summary>
|
|
312
|
+
/// <returns>all data related to CCPA consent management</returns>
|
|
313
|
+
public CCPAData GetUSPData()
|
|
314
|
+
{
|
|
315
|
+
ensureSupportedPlatform();
|
|
316
|
+
logDebug("GetUSPData Invoked");
|
|
317
|
+
ensureInitialized();
|
|
318
|
+
|
|
319
|
+
var rawCCPAData = UsercentricsPlatform?.GetUSPData();
|
|
320
|
+
logDebug(rawCCPAData);
|
|
321
|
+
var ccpaData = JsonUtility.FromJson<CCPAData>(rawCCPAData);
|
|
322
|
+
|
|
323
|
+
return ccpaData;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/// <summary>
|
|
327
|
+
/// Get the First Layer Settings Data.
|
|
328
|
+
/// This method only returns data when using TCF Framework.
|
|
329
|
+
/// In case your Settings ID is using other configuration, no data will be returned.
|
|
330
|
+
/// </summary>
|
|
331
|
+
/// <returns>First layer data related to TCF Framework</returns>
|
|
332
|
+
public FirstLayerSettings GetFirstLayerSettings()
|
|
333
|
+
{
|
|
334
|
+
ensureSupportedPlatform();
|
|
335
|
+
logDebug("GetFirstLayerSettings Invoked");
|
|
336
|
+
ensureInitialized();
|
|
337
|
+
|
|
338
|
+
var rawFirstLayerSettings = UsercentricsPlatform?.GetFirstLayerSettings();
|
|
339
|
+
logDebug(rawFirstLayerSettings);
|
|
340
|
+
var firstLayerSettings = JsonUtility.FromJson<FirstLayerSettings>(rawFirstLayerSettings);
|
|
341
|
+
|
|
342
|
+
return firstLayerSettings;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/// <summary>
|
|
346
|
+
/// Available only when using TCF Framework.
|
|
347
|
+
/// Accept All button action. Use this method to signal when users presses this button.
|
|
348
|
+
/// Only First Layer is supported.
|
|
349
|
+
/// </summary>
|
|
350
|
+
public void AcceptAll()
|
|
351
|
+
{
|
|
352
|
+
ensureSupportedPlatform();
|
|
353
|
+
logDebug("AcceptAll Invoked");
|
|
354
|
+
ensureInitialized();
|
|
355
|
+
|
|
356
|
+
UsercentricsPlatform?.AcceptAll();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/// <summary>
|
|
360
|
+
/// Available only when using TCF Framework.
|
|
361
|
+
/// Deny All button action. Use this method to signal when users presses this button.
|
|
362
|
+
/// Only First Layer is supported.
|
|
363
|
+
/// </summary>
|
|
364
|
+
/// <param name="unsavedPurposeLIDecisions">
|
|
365
|
+
/// Optional JSON string with purpose legitimate interest decisions.
|
|
366
|
+
/// Format: {"purposeId": true/false, ...}
|
|
367
|
+
/// Example: {"1":true,"2":false}
|
|
368
|
+
/// </param>
|
|
369
|
+
/// <param name="unsavedVendorLIDecisions">
|
|
370
|
+
/// Optional JSON string with vendor legitimate interest decisions.
|
|
371
|
+
/// Format: {"vendorId": true/false, ...}
|
|
372
|
+
/// Example: {"1":true,"2":false}
|
|
373
|
+
/// </param>
|
|
374
|
+
public void DenyAll(string unsavedPurposeLIDecisions = null, string unsavedVendorLIDecisions = null)
|
|
375
|
+
{
|
|
376
|
+
ensureSupportedPlatform();
|
|
377
|
+
logDebug("DenyAll Invoked");
|
|
378
|
+
ensureInitialized();
|
|
379
|
+
|
|
380
|
+
UsercentricsPlatform?.DenyAll(unsavedPurposeLIDecisions, unsavedVendorLIDecisions);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/// <summary>
|
|
384
|
+
/// Available only when using GDPR Framework.
|
|
385
|
+
/// Accept All button action. Use this method to signal when users presses this button.
|
|
386
|
+
/// Only First Layer is supported.
|
|
387
|
+
/// </summary>
|
|
388
|
+
public void AcceptAllForGDPR()
|
|
389
|
+
{
|
|
390
|
+
ensureSupportedPlatform();
|
|
391
|
+
logDebug("AcceptAll For GDPR Invoked");
|
|
392
|
+
ensureInitialized();
|
|
393
|
+
|
|
394
|
+
UsercentricsPlatform?.AcceptAllForGDPR();
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/// <summary>
|
|
398
|
+
/// Available only when using GDPR Framework.
|
|
399
|
+
/// Deny All button action. Use this method to signal when users presses this button.
|
|
400
|
+
/// Only First Layer is supported.
|
|
401
|
+
/// </summary>
|
|
402
|
+
public void DenyAllForGDPR()
|
|
403
|
+
{
|
|
404
|
+
ensureSupportedPlatform();
|
|
405
|
+
logDebug("DenyAll For GDPR Invoked");
|
|
406
|
+
ensureInitialized();
|
|
407
|
+
|
|
408
|
+
UsercentricsPlatform?.DenyAllForGDPR();
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
/// <summary>
|
|
413
|
+
/// Restore Consents given by a user using its Controller ID.
|
|
414
|
+
/// </summary>
|
|
415
|
+
/// <param name="controllerId">
|
|
416
|
+
/// User's Controller Id string.
|
|
417
|
+
/// </param>
|
|
418
|
+
/// <param name="successCallback">
|
|
419
|
+
/// Callback block that is invoked when the restoration completes successfully.
|
|
420
|
+
/// It returns UsercentricsReadyStatus.
|
|
421
|
+
/// </param>
|
|
422
|
+
/// <param name="initializeErrorCallback">
|
|
423
|
+
/// Callback block that is invoked when the initialize process finishes
|
|
424
|
+
/// with an error.
|
|
425
|
+
/// It returns a non-localized string with information about the error.
|
|
426
|
+
/// </param>
|
|
427
|
+
public void RestoreUserSession(
|
|
428
|
+
string controllerId,
|
|
429
|
+
UnityAction<UsercentricsReadyStatus> successCallback,
|
|
430
|
+
UnityAction<string> errorCallback
|
|
431
|
+
){
|
|
432
|
+
ensureSupportedPlatform();
|
|
433
|
+
logDebug("RestoreUserSession invoked");
|
|
434
|
+
|
|
435
|
+
this.restoreSessionSuccessCallback = successCallback;
|
|
436
|
+
this.restoreSessionErrorCallback = errorCallback;
|
|
437
|
+
|
|
438
|
+
UsercentricsPlatform?.RestoreUserSession(controllerId);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/// <summary>
|
|
442
|
+
/// Subscribe to any consent updated event that happens within Usercentrics SDK
|
|
443
|
+
/// </summary>
|
|
444
|
+
public void SubscribeOnConsentUpdated(UnityAction<UsercentricsUpdatedConsentEvent> callback)
|
|
445
|
+
{
|
|
446
|
+
ensureSupportedPlatform();
|
|
447
|
+
logDebug("SubscribeOnConsentUpdated invoked");
|
|
448
|
+
if (consentUpdateSubscriptionCoordinator.RegisterPublicSubscriber())
|
|
449
|
+
{
|
|
450
|
+
UsercentricsPlatform?.SubscribeOnConsentUpdated();
|
|
451
|
+
}
|
|
452
|
+
this.onConsentUpdatedCallbacks.Add(callback);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/// <summary>
|
|
456
|
+
/// Dispose all callbacks related to OnConsentUpdated event
|
|
457
|
+
/// </summary>
|
|
458
|
+
public void DisposeOnConsentUpdatedSubscription()
|
|
459
|
+
{
|
|
460
|
+
ensureSupportedPlatform();
|
|
461
|
+
logDebug("DisposeOnConsentUpdatedSubscription invoked");
|
|
462
|
+
this.onConsentUpdatedCallbacks.Clear();
|
|
463
|
+
// The internal Unity Consent Mode listener (see ApplyUnityConsentModeIfEnabled)
|
|
464
|
+
// shares the native subscription and must keep receiving updates even after
|
|
465
|
+
// a game disposes its own public subscription.
|
|
466
|
+
if (consentUpdateSubscriptionCoordinator.ClearPublicSubscribers())
|
|
467
|
+
{
|
|
468
|
+
UsercentricsPlatform?.DisposeOnConsentUpdatedSubscription();
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/// <summary>
|
|
473
|
+
/// Subscribe to any mediation event that happens within Usercentrics SDK
|
|
474
|
+
/// </summary>
|
|
475
|
+
public void SubscribeOnConsentMediation(UnityAction<UsercentricsMediationEvent> callback)
|
|
476
|
+
{
|
|
477
|
+
ensureSupportedPlatform();
|
|
478
|
+
logDebug("SubscribeOnConsentMediation invoked");
|
|
479
|
+
if (onConsentMediationCallbacks.Count == 0)
|
|
480
|
+
{
|
|
481
|
+
UsercentricsPlatform?.SubscribeOnConsentMediation();
|
|
482
|
+
}
|
|
483
|
+
this.onConsentMediationCallbacks.Add(callback);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/// <summary>
|
|
487
|
+
/// Dispose all callbacks related to OnConsentMediation event
|
|
488
|
+
/// </summary>
|
|
489
|
+
public void DisposeOnConsentMediationSubscription()
|
|
490
|
+
{
|
|
491
|
+
ensureSupportedPlatform();
|
|
492
|
+
logDebug("DisposeOnConsentMediationSubscription invoked");
|
|
493
|
+
this.onConsentMediationCallbacks.Clear();
|
|
494
|
+
UsercentricsPlatform?.DisposeOnConsentMediationSubscription();
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/// <summary>
|
|
498
|
+
/// Track events using our Interaction Analytics API, so they can be displayed in Usercentrics analytics dashboard
|
|
499
|
+
/// </summary>
|
|
500
|
+
public void Track(UsercentricsAnalyticsEventType eventType)
|
|
501
|
+
{
|
|
502
|
+
ensureSupportedPlatform();
|
|
503
|
+
logDebug("Track invoked");
|
|
504
|
+
|
|
505
|
+
UsercentricsPlatform?.Track((int) eventType);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/// <summary>
|
|
509
|
+
/// When building your own TCF 2.0 CMP, it is required to have your CMP UI design certified by
|
|
510
|
+
/// the [IAB](https://iabeurope.eu/tcf-2-0/). Once certified, you will need to provide your CMP Id using this API
|
|
511
|
+
/// </summary>
|
|
512
|
+
public void SetCmpId(int cmpId)
|
|
513
|
+
{
|
|
514
|
+
ensureSupportedPlatform();
|
|
515
|
+
logDebug("Set CmpId invoked");
|
|
516
|
+
|
|
517
|
+
UsercentricsPlatform?.SetCmpId(cmpId);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/// <summary>
|
|
521
|
+
/// Get the CMP Data
|
|
522
|
+
/// </summary>
|
|
523
|
+
/// <returns>CMP useful data</returns>
|
|
524
|
+
public CmpData GetCmpData()
|
|
525
|
+
{
|
|
526
|
+
ensureSupportedPlatform();
|
|
527
|
+
logDebug("GetCmpData Invoked");
|
|
528
|
+
ensureInitialized();
|
|
529
|
+
|
|
530
|
+
var rawCmpData = UsercentricsPlatform?.GetCmpData();
|
|
531
|
+
logDebug(rawCmpData);
|
|
532
|
+
|
|
533
|
+
var cmpData = JsonUtility.FromJson<CmpData>(rawCmpData);
|
|
534
|
+
return cmpData;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/// <summary>
|
|
538
|
+
/// Sets the variant for AB testing
|
|
539
|
+
/// </summary>
|
|
540
|
+
public void SetABTestingVariant(string variant)
|
|
541
|
+
{
|
|
542
|
+
ensureSupportedPlatform();
|
|
543
|
+
logDebug("Set AB Testing Variant invoked");
|
|
544
|
+
ensureInitialized();
|
|
545
|
+
|
|
546
|
+
UsercentricsPlatform?.SetABTestingVariant(variant);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/// <summary>
|
|
550
|
+
/// Gets the variant for AB testing
|
|
551
|
+
/// </summary>
|
|
552
|
+
/// <returns>AB Testing Variant</returns>
|
|
553
|
+
public string GetABTestingVariant()
|
|
554
|
+
{
|
|
555
|
+
ensureSupportedPlatform();
|
|
556
|
+
logDebug("GetABTestingVariant Invoked");
|
|
557
|
+
ensureInitialized();
|
|
558
|
+
|
|
559
|
+
return UsercentricsPlatform?.GetABTestingVariant();
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/// <summary>
|
|
563
|
+
/// Get the Additional Consent Mode Data with the AC string and selected Ad Tech Providers
|
|
564
|
+
/// </summary>
|
|
565
|
+
/// <returns>CMP useful data</returns>
|
|
566
|
+
public AdditionalConsentModeData GetAdditionalConsentModeData()
|
|
567
|
+
{
|
|
568
|
+
ensureSupportedPlatform();
|
|
569
|
+
logDebug("GetAdditionalConsentModeData Invoked");
|
|
570
|
+
ensureInitialized();
|
|
571
|
+
|
|
572
|
+
var rawAcmData = UsercentricsPlatform?.GetAdditionalConsentModeData();
|
|
573
|
+
logDebug(rawAcmData);
|
|
574
|
+
|
|
575
|
+
var acmData = JsonUtility.FromJson<AdditionalConsentModeData>(rawAcmData);
|
|
576
|
+
return acmData;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/// <summary>
|
|
580
|
+
/// Get DPS metadata for a given template ID.
|
|
581
|
+
/// </summary>
|
|
582
|
+
/// <param name="templateId">The template ID to retrieve metadata for.</param>
|
|
583
|
+
/// <returns>
|
|
584
|
+
/// A JSON string representing the metadata dictionary, or null if the template ID is not found.
|
|
585
|
+
/// Returns an empty JSON object ("{}") if metadata is absent or empty.
|
|
586
|
+
/// </returns>
|
|
587
|
+
public string GetDpsMetadata(string templateId)
|
|
588
|
+
{
|
|
589
|
+
ensureSupportedPlatform();
|
|
590
|
+
logDebug("GetDpsMetadata Invoked");
|
|
591
|
+
ensureInitialized();
|
|
592
|
+
|
|
593
|
+
var rawDpsMetadata = UsercentricsPlatform?.GetDpsMetadata(templateId);
|
|
594
|
+
logDebug(rawDpsMetadata);
|
|
595
|
+
|
|
596
|
+
return rawDpsMetadata;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/// <summary>
|
|
600
|
+
/// Get Consents
|
|
601
|
+
/// </summary>
|
|
602
|
+
/// <returns>Consents</returns>
|
|
603
|
+
public List<UsercentricsServiceConsent> GetConsents()
|
|
604
|
+
{
|
|
605
|
+
ensureSupportedPlatform();
|
|
606
|
+
logDebug("GetConsents Invoked");
|
|
607
|
+
ensureInitialized();
|
|
608
|
+
|
|
609
|
+
var rawConsents = UsercentricsPlatform?.GetConsents();
|
|
610
|
+
logDebug(rawConsents);
|
|
611
|
+
|
|
612
|
+
var usercentricsConsents = JsonUtility.FromJson<UsercentricsConsentsHolder>(rawConsents).consents;
|
|
613
|
+
|
|
614
|
+
return usercentricsConsents;
|
|
615
|
+
}
|
|
616
|
+
/// <summary>
|
|
617
|
+
/// Get the GPP data including gppString, applicableSections, and sections.
|
|
618
|
+
/// </summary>
|
|
619
|
+
public GppData GetGPPData()
|
|
620
|
+
{
|
|
621
|
+
ensureSupportedPlatform();
|
|
622
|
+
logDebug("GetGPPData Invoked");
|
|
623
|
+
ensureInitialized();
|
|
624
|
+
|
|
625
|
+
var rawGppData = UsercentricsPlatform?.GetGPPData();
|
|
626
|
+
logDebug(rawGppData);
|
|
627
|
+
var gppData = JsonUtility.FromJson<GppData>(rawGppData);
|
|
628
|
+
gppData.sections = ExtractSectionsJson(rawGppData);
|
|
629
|
+
|
|
630
|
+
return gppData;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
private string ExtractSectionsJson(string rawJson)
|
|
634
|
+
{
|
|
635
|
+
if (string.IsNullOrEmpty(rawJson)) return null;
|
|
636
|
+
var key = "\"sections\":";
|
|
637
|
+
int idx = rawJson.IndexOf(key);
|
|
638
|
+
if (idx < 0) return null;
|
|
639
|
+
int start = idx + key.Length;
|
|
640
|
+
if (start >= rawJson.Length || rawJson[start] != '{') return null;
|
|
641
|
+
int depth = 0;
|
|
642
|
+
for (int i = start; i < rawJson.Length; i++)
|
|
643
|
+
{
|
|
644
|
+
if (rawJson[i] == '{') depth++;
|
|
645
|
+
else if (rawJson[i] == '}') depth--;
|
|
646
|
+
if (depth == 0) return rawJson.Substring(start, i - start + 1);
|
|
647
|
+
}
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/// <summary>
|
|
652
|
+
/// Get the GPP string for transmission to vendors.
|
|
653
|
+
/// </summary>
|
|
654
|
+
public string GetGPPString()
|
|
655
|
+
{
|
|
656
|
+
ensureSupportedPlatform();
|
|
657
|
+
logDebug("GetGPPString Invoked");
|
|
658
|
+
ensureInitialized();
|
|
659
|
+
|
|
660
|
+
return UsercentricsPlatform?.GetGPPString();
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/// <summary>
|
|
664
|
+
/// Set a GPP consent field value.
|
|
665
|
+
/// </summary>
|
|
666
|
+
public void SetGPPConsent(string sectionName, string fieldName, string value)
|
|
667
|
+
{
|
|
668
|
+
ensureSupportedPlatform();
|
|
669
|
+
logDebug("SetGPPConsent Invoked");
|
|
670
|
+
ensureInitialized();
|
|
671
|
+
|
|
672
|
+
var args = new SetGPPConsentArgs(sectionName, fieldName, value);
|
|
673
|
+
var argsJson = JsonUtility.ToJson(args);
|
|
674
|
+
UsercentricsPlatform?.SetGPPConsent(argsJson);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/// <summary>
|
|
678
|
+
/// Subscribe to GPP section change events.
|
|
679
|
+
/// </summary>
|
|
680
|
+
public void SubscribeOnGppSectionChange(UnityAction<GppSectionChangeEvent> callback)
|
|
681
|
+
{
|
|
682
|
+
ensureSupportedPlatform();
|
|
683
|
+
logDebug("SubscribeOnGppSectionChange invoked");
|
|
684
|
+
if (onGppSectionChangeCallbacks.Count == 0)
|
|
685
|
+
{
|
|
686
|
+
UsercentricsPlatform?.SubscribeOnGppSectionChange();
|
|
687
|
+
}
|
|
688
|
+
this.onGppSectionChangeCallbacks.Add(callback);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/// <summary>
|
|
692
|
+
/// Dispose all callbacks related to GppSectionChange event.
|
|
693
|
+
/// </summary>
|
|
694
|
+
public void DisposeOnGppSectionChangeSubscription()
|
|
695
|
+
{
|
|
696
|
+
ensureSupportedPlatform();
|
|
697
|
+
logDebug("DisposeOnGppSectionChangeSubscription invoked");
|
|
698
|
+
this.onGppSectionChangeCallbacks.Clear();
|
|
699
|
+
UsercentricsPlatform?.DisposeOnGppSectionChangeSubscription();
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
#endregion
|
|
703
|
+
|
|
704
|
+
/// <summary>
|
|
705
|
+
/// Clears user's session avoiding the sdk initialization.
|
|
706
|
+
/// </param>
|
|
707
|
+
/// <param name="successCallback">
|
|
708
|
+
/// Callback block that is invoked when the restoration completes successfully.
|
|
709
|
+
/// It returns UsercentricsReadyStatus.
|
|
710
|
+
/// </param>
|
|
711
|
+
/// <param name="initializeErrorCallback">
|
|
712
|
+
/// Callback block that is invoked when the initialize process finishes
|
|
713
|
+
/// with an error.
|
|
714
|
+
/// It returns a non-localized string with information about the error.
|
|
715
|
+
/// </param>
|
|
716
|
+
public void ClearUserSession(
|
|
717
|
+
UnityAction<UsercentricsReadyStatus> successCallback,
|
|
718
|
+
UnityAction<string> errorCallback
|
|
719
|
+
){
|
|
720
|
+
ensureSupportedPlatform();
|
|
721
|
+
logDebug("ClearUserSession invoked");
|
|
722
|
+
ensureInitialized();
|
|
723
|
+
|
|
724
|
+
this.clearSessionSuccessCallback = successCallback;
|
|
725
|
+
this.clearSessionErrorCallback = errorCallback;
|
|
726
|
+
|
|
727
|
+
UsercentricsPlatform?.ClearUserSession();
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/// <summary>
|
|
731
|
+
/// Notifies the SDK that the host app successfully logged the user in during a Consent or Pay
|
|
732
|
+
/// (PUR) flow. Clears stored TCF consent data, treating it as an implicit deny decision.
|
|
733
|
+
/// Does not dismiss the banner — the host app remains responsible for that.
|
|
734
|
+
/// </summary>
|
|
735
|
+
/// <param name="successCallback">Invoked when the success signal was handled.</param>
|
|
736
|
+
/// <param name="errorCallback">Invoked with an error message if handling the signal failed.</param>
|
|
737
|
+
public void NotifyLoginSuccess(
|
|
738
|
+
UnityAction successCallback,
|
|
739
|
+
UnityAction<string> errorCallback
|
|
740
|
+
){
|
|
741
|
+
ensureSupportedPlatform();
|
|
742
|
+
logDebug("NotifyLoginSuccess invoked");
|
|
743
|
+
ensureInitialized();
|
|
744
|
+
|
|
745
|
+
this.notifyLoginSuccessCallback = successCallback;
|
|
746
|
+
this.notifyLoginErrorCallback = errorCallback;
|
|
747
|
+
|
|
748
|
+
UsercentricsPlatform?.NotifyLoginSuccess();
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/// <summary>
|
|
752
|
+
/// Notifies the SDK that the host app successfully subscribed the user during a Consent or Pay
|
|
753
|
+
/// (PUR) flow. Clears stored TCF consent data, treating it as an implicit deny decision.
|
|
754
|
+
/// Does not dismiss the banner — the host app remains responsible for that.
|
|
755
|
+
/// </summary>
|
|
756
|
+
/// <param name="successCallback">Invoked when the success signal was handled.</param>
|
|
757
|
+
/// <param name="errorCallback">Invoked with an error message if handling the signal failed.</param>
|
|
758
|
+
public void NotifySubscribeSuccess(
|
|
759
|
+
UnityAction successCallback,
|
|
760
|
+
UnityAction<string> errorCallback
|
|
761
|
+
){
|
|
762
|
+
ensureSupportedPlatform();
|
|
763
|
+
logDebug("NotifySubscribeSuccess invoked");
|
|
764
|
+
ensureInitialized();
|
|
765
|
+
|
|
766
|
+
this.notifySubscribeSuccessCallback = successCallback;
|
|
767
|
+
this.notifySubscribeErrorCallback = errorCallback;
|
|
768
|
+
|
|
769
|
+
UsercentricsPlatform?.NotifySubscribeSuccess();
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/// <summary>
|
|
773
|
+
/// Notifies the SDK that the host app's user is no longer an active Consent or Pay (PUR)
|
|
774
|
+
/// subscriber (e.g. their subscription lapsed or was cancelled). Resets the subscriber flag
|
|
775
|
+
/// so the host app can re-surface the Consent-or-Pay banner; does not alter any existing
|
|
776
|
+
/// consent data, which remains accurate.
|
|
777
|
+
/// </summary>
|
|
778
|
+
/// <param name="successCallback">Invoked when the signal was handled.</param>
|
|
779
|
+
/// <param name="errorCallback">Invoked with an error message if handling the signal failed.</param>
|
|
780
|
+
public void NotifySubscriptionLapsed(
|
|
781
|
+
UnityAction successCallback,
|
|
782
|
+
UnityAction<string> errorCallback
|
|
783
|
+
){
|
|
784
|
+
ensureSupportedPlatform();
|
|
785
|
+
logDebug("NotifySubscriptionLapsed invoked");
|
|
786
|
+
ensureInitialized();
|
|
787
|
+
|
|
788
|
+
this.notifySubscriptionLapsedSuccessCallback = successCallback;
|
|
789
|
+
this.notifySubscriptionLapsedErrorCallback = errorCallback;
|
|
790
|
+
|
|
791
|
+
UsercentricsPlatform?.NotifySubscriptionLapsed();
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/// <summary>
|
|
795
|
+
/// Change the CMP language without reinitializing the SDK.
|
|
796
|
+
/// After success, call GetCMPData() or GetConsents() to retrieve translated strings.
|
|
797
|
+
/// </summary>
|
|
798
|
+
/// <param name="language">BCP-47 language code (e.g. "de", "fr").</param>
|
|
799
|
+
/// <param name="successCallback">Invoked when the language was changed successfully.</param>
|
|
800
|
+
/// <param name="errorCallback">Invoked with an error message if the language change failed.</param>
|
|
801
|
+
public void ChangeLanguage(
|
|
802
|
+
string language,
|
|
803
|
+
UnityAction successCallback,
|
|
804
|
+
UnityAction<string> errorCallback
|
|
805
|
+
){
|
|
806
|
+
ensureSupportedPlatform();
|
|
807
|
+
logDebug("ChangeLanguage invoked");
|
|
808
|
+
ensureInitialized();
|
|
809
|
+
|
|
810
|
+
this.changeLanguageSuccessCallback = successCallback;
|
|
811
|
+
this.changeLanguageErrorCallback = errorCallback;
|
|
812
|
+
|
|
813
|
+
UsercentricsPlatform?.ChangeLanguage(language);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/// <summary>
|
|
817
|
+
/// EXPERIMENTAL (MSDK-4778, signal receiver mode): this API may change or be removed in any release.
|
|
818
|
+
/// Hands the SDK an age range the host app already knows about its user, for example a "16+" flag
|
|
819
|
+
/// from the host's own age gate. Build the signal with UsercentricsPublisherAgeSignal.AtLeast,
|
|
820
|
+
/// Below or Between.
|
|
821
|
+
///
|
|
822
|
+
/// The SDK checks the range, tags it as provided by the publisher (PublisherProvided, which the host
|
|
823
|
+
/// cannot change, so it is never mistaken for an age that a platform verified), resolves the band with
|
|
824
|
+
/// the same rules as the Apple and Google signals and writes one line to the SDK logger (visible with
|
|
825
|
+
/// DebugMode, without the ages). With the default thresholds "16+" is Minor and "under 16" is BelowMinimum.
|
|
826
|
+
///
|
|
827
|
+
/// The signal counts from now on and the last call wins. Nothing is stored or sent, and consent does not
|
|
828
|
+
/// change. Send it again after each start.
|
|
829
|
+
///
|
|
830
|
+
/// Call it once the SDK is initialized (it throws NotInitializedException before). The SDK never throws
|
|
831
|
+
/// for the range itself: a range that is not valid (no age, an age outside 0..120, a lower age above the
|
|
832
|
+
/// upper one, a label that is not 1 to 32 characters of A-Z a-z 0-9 . _ -) comes back through the error
|
|
833
|
+
/// callback as a fixed message that does not repeat what was passed.
|
|
834
|
+
///
|
|
835
|
+
/// One request is tracked at a time: call it again only after one of the callbacks has fired.
|
|
836
|
+
/// </summary>
|
|
837
|
+
/// <param name="signal">The age range, built with UsercentricsPublisherAgeSignal.</param>
|
|
838
|
+
/// <param name="successCallback">
|
|
839
|
+
/// Invoked with the resulting UsercentricsAgeSignalDecision (see UsercentricsAgeSignalDecision.band).
|
|
840
|
+
/// </param>
|
|
841
|
+
/// <param name="errorCallback">
|
|
842
|
+
/// Invoked with a non-localized message when the signal could not be processed, for example because the
|
|
843
|
+
/// range is not valid.
|
|
844
|
+
/// </param>
|
|
845
|
+
public void SetAgeSignal(
|
|
846
|
+
UsercentricsPublisherAgeSignal signal,
|
|
847
|
+
UnityAction<UsercentricsAgeSignalDecision> successCallback,
|
|
848
|
+
UnityAction<string> errorCallback
|
|
849
|
+
){
|
|
850
|
+
ensureSupportedPlatform();
|
|
851
|
+
// Nothing of the signal or of the decision is logged here: both carry the age range
|
|
852
|
+
logDebug("SetAgeSignal invoked");
|
|
853
|
+
ensureInitialized();
|
|
854
|
+
|
|
855
|
+
if (signal == null)
|
|
856
|
+
{
|
|
857
|
+
throw new ArgumentNullException(nameof(signal));
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
this.setAgeSignalSuccessCallback = successCallback;
|
|
861
|
+
this.setAgeSignalErrorCallback = errorCallback;
|
|
862
|
+
|
|
863
|
+
var signalJson = JsonUtility.ToJson(signal.ToRequest());
|
|
864
|
+
|
|
865
|
+
UsercentricsPlatform?.SetAgeSignal(signalJson);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/// <summary>
|
|
869
|
+
/// Available only when using GDPR Framework.
|
|
870
|
+
/// Save Decisions button action. Use this method to signal when users presses this button.
|
|
871
|
+
/// Only First Layer is supported.
|
|
872
|
+
/// </summary>
|
|
873
|
+
public List<UsercentricsServiceConsent> saveDecisionsForGDPR(List<UsercentricsUserDecision> decisions)
|
|
874
|
+
{
|
|
875
|
+
ensureSupportedPlatform();
|
|
876
|
+
logDebug("saveDecisionsGDPR For GDPR Invoked");
|
|
877
|
+
ensureInitialized();
|
|
878
|
+
|
|
879
|
+
var wrapper = new UsercentricsUserDecisionListWrapper { decisions = decisions };
|
|
880
|
+
var decisionsJson = JsonUtility.ToJson(wrapper, true);
|
|
881
|
+
logDebug(decisionsJson);
|
|
882
|
+
|
|
883
|
+
var rawServiceConsent = UsercentricsPlatform?.SaveDecisionsForGDPR(decisionsJson);
|
|
884
|
+
logDebug(rawServiceConsent);
|
|
885
|
+
|
|
886
|
+
var data = JsonUtility.FromJson<UsercentricsServiceConsentWrapper>(rawServiceConsent);
|
|
887
|
+
return data.consents;
|
|
888
|
+
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
#region UTILS
|
|
892
|
+
|
|
893
|
+
private void ensureInitialized()
|
|
894
|
+
{
|
|
895
|
+
if (!IsInitialized)
|
|
896
|
+
{
|
|
897
|
+
throw new NotInitializedException();
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
private void ensureSupportedPlatform()
|
|
902
|
+
{
|
|
903
|
+
ShowEditorNotSupportedDialogIfNeeded();
|
|
904
|
+
|
|
905
|
+
if (!IsPlatformSupported())
|
|
906
|
+
{
|
|
907
|
+
throw new PlatformSupportException();
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
private void ShowEditorNotSupportedDialogIfNeeded()
|
|
912
|
+
{
|
|
913
|
+
#if UNITY_EDITOR
|
|
914
|
+
bool openRequirements = EditorUtility.DisplayDialog("Unity Editor not supported", UCConstants.UNITY_EDITOR_MESSAGE, "See Documentation", "Close");
|
|
915
|
+
if (openRequirements)
|
|
916
|
+
{
|
|
917
|
+
Help.BrowseURL(UCConstants.REQUIREMENTS_URL);
|
|
918
|
+
}
|
|
919
|
+
#endif
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
private void logDebug(string message)
|
|
923
|
+
{
|
|
924
|
+
if (Options.DebugMode)
|
|
925
|
+
{
|
|
926
|
+
Debug.Log("[USERCENTRICS][DEBUG] " + message);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
private BannerSettings BuildBannerSettingsWithOptions(BannerSettings bannerSettings)
|
|
931
|
+
{
|
|
932
|
+
if (bannerSettings == null)
|
|
933
|
+
{
|
|
934
|
+
return new BannerSettings(generalStyleSettings: GetGeneralStyleSettingsFromOptions(),
|
|
935
|
+
firstLayerStyleSettings: null,
|
|
936
|
+
secondLayerStyleSettings: null,
|
|
937
|
+
variantName: null);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
if (bannerSettings.generalStyleSettings == null)
|
|
941
|
+
{
|
|
942
|
+
bannerSettings.generalStyleSettings = GetGeneralStyleSettingsFromOptions();
|
|
943
|
+
}
|
|
944
|
+
return bannerSettings;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
private GeneralStyleSettings GetGeneralStyleSettingsFromOptions()
|
|
948
|
+
{
|
|
949
|
+
var isSystemBackButtonDisabled = Options.Android.DisableSystemBackButton;
|
|
950
|
+
var statusBarColor = Options.Android.StatusBarColor;
|
|
951
|
+
var showWindowInFullscreen = Options.Android.ShowWindowInFullscreen;
|
|
952
|
+
|
|
953
|
+
return new GeneralStyleSettings(androidDisableSystemBackButton: isSystemBackButtonDisabled,
|
|
954
|
+
androidStatusBarColor: statusBarColor,
|
|
955
|
+
androidWindowFullscreen: showWindowInFullscreen);
|
|
956
|
+
}
|
|
957
|
+
#endregion
|
|
958
|
+
|
|
959
|
+
#region MESSAGES HANDLERS
|
|
960
|
+
#pragma warning disable IDE0051 // Remove unused private members
|
|
961
|
+
internal void HandleInitSuccess(string rawUsercentricsReadyStatus)
|
|
962
|
+
{
|
|
963
|
+
logDebug("HandleInitSuccess UsercentricsReadyStatus=" + rawUsercentricsReadyStatus);
|
|
964
|
+
var usercentricsReadyStatus = JsonUtility.FromJson<UsercentricsReadyStatus>(rawUsercentricsReadyStatus);
|
|
965
|
+
this.IsInitialized = true;
|
|
966
|
+
ApplyUnityConsentModeIfEnabled(usercentricsReadyStatus.consents);
|
|
967
|
+
|
|
968
|
+
this.initializeCallback?.Invoke(usercentricsReadyStatus);
|
|
969
|
+
this.initializeCallback = null;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
internal void HandleInitError(string errorMessage)
|
|
973
|
+
{
|
|
974
|
+
logDebug("HandleInitError errorMessage=" + errorMessage);
|
|
975
|
+
this.initializeErrorCallback?.Invoke(errorMessage);
|
|
976
|
+
this.initializeErrorCallback = null;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
internal void HandleBannerResponse(string rawUsercentricsConsentUserResponse)
|
|
980
|
+
{
|
|
981
|
+
logDebug("HandleBannerResponse UsercentricsConsentUserResponse=" + rawUsercentricsConsentUserResponse);
|
|
982
|
+
var usercentricsConsentUserResponse = JsonUtility.FromJson<UsercentricsConsentUserResponse>(rawUsercentricsConsentUserResponse);
|
|
983
|
+
this.onDismissCallback?.Invoke(usercentricsConsentUserResponse);
|
|
984
|
+
this.onDismissCallback = null;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
internal void HandleRestoreSuccess(string rawUsercentricsReadyStatus)
|
|
988
|
+
{
|
|
989
|
+
logDebug("HandleRestoreSuccess UsercentricsReadyStatus=" + rawUsercentricsReadyStatus);
|
|
990
|
+
var usercentricsReadyStatus = JsonUtility.FromJson<UsercentricsReadyStatus>(rawUsercentricsReadyStatus);
|
|
991
|
+
ApplyUnityConsentModeIfEnabled(usercentricsReadyStatus.consents);
|
|
992
|
+
this.restoreSessionSuccessCallback?.Invoke(usercentricsReadyStatus);
|
|
993
|
+
this.restoreSessionSuccessCallback = null;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
internal void HandleRestoreError(string errorMessage)
|
|
997
|
+
{
|
|
998
|
+
logDebug("HandleRestoreError errorMessage=" + errorMessage);
|
|
999
|
+
this.restoreSessionErrorCallback?.Invoke(errorMessage);
|
|
1000
|
+
this.restoreSessionErrorCallback = null;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
internal void HandleTCFData(string rawTCFData)
|
|
1004
|
+
{
|
|
1005
|
+
logDebug("HandleTCFData tcfData=" + rawTCFData);
|
|
1006
|
+
var tcfData = JsonUtility.FromJson<TCFData>(rawTCFData);
|
|
1007
|
+
this.tcfDataCallback?.Invoke(tcfData);
|
|
1008
|
+
this.tcfDataCallback = null;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
internal void HandleOnConsentUpdated(string rawUsercentricsUpdatedConsentEvent)
|
|
1012
|
+
{
|
|
1013
|
+
logDebug("HandleOnConsentUpdated usercentricsUpdatedConsentEvent=" + rawUsercentricsUpdatedConsentEvent);
|
|
1014
|
+
var usercentricsUpdatedConsentEvent = JsonUtility.FromJson<UsercentricsUpdatedConsentEvent>(rawUsercentricsUpdatedConsentEvent);
|
|
1015
|
+
if (Options.UnityConsentMode.Enabled)
|
|
1016
|
+
{
|
|
1017
|
+
unityConsentModeAdapter.Apply(usercentricsUpdatedConsentEvent.consents);
|
|
1018
|
+
}
|
|
1019
|
+
this.onConsentUpdatedCallbacks?.ForEach(callback => callback.Invoke(usercentricsUpdatedConsentEvent));
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
private void ApplyUnityConsentModeIfEnabled(List<UsercentricsServiceConsent> consents)
|
|
1023
|
+
{
|
|
1024
|
+
if (!Options.UnityConsentMode.Enabled)
|
|
1025
|
+
{
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
unityConsentModeAdapter.Apply(consents);
|
|
1030
|
+
|
|
1031
|
+
if (consentUpdateSubscriptionCoordinator.RegisterInternalSubscription())
|
|
1032
|
+
{
|
|
1033
|
+
UsercentricsPlatform?.SubscribeOnConsentUpdated();
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
internal void HandleOnConsentMediation(string rawUsercentricsMediationEvent)
|
|
1038
|
+
{
|
|
1039
|
+
logDebug("HandleOnConsentMediation usercentricsMediationEvent=" + rawUsercentricsMediationEvent);
|
|
1040
|
+
var usercentricsMediationEvent = JsonUtility.FromJson<UsercentricsMediationEvent>(rawUsercentricsMediationEvent);
|
|
1041
|
+
this.onConsentMediationCallbacks?.ForEach(callback => callback.Invoke(usercentricsMediationEvent));
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
internal void HandleGppSectionChange(string rawGppSectionChangeEvent)
|
|
1045
|
+
{
|
|
1046
|
+
logDebug("HandleGppSectionChange gppSectionChangeEvent=" + rawGppSectionChangeEvent);
|
|
1047
|
+
var gppSectionChangeEvent = JsonUtility.FromJson<GppSectionChangeEvent>(rawGppSectionChangeEvent);
|
|
1048
|
+
this.onGppSectionChangeCallbacks?.ForEach(callback => callback.Invoke(gppSectionChangeEvent));
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
internal void HandleClearSuccess(string rawUsercentricsReadyStatus)
|
|
1052
|
+
{
|
|
1053
|
+
logDebug("HandleClearSuccess UsercentricsReadyStatus=" + rawUsercentricsReadyStatus);
|
|
1054
|
+
var usercentricsReadyStatus = JsonUtility.FromJson<UsercentricsReadyStatus>(rawUsercentricsReadyStatus);
|
|
1055
|
+
ApplyUnityConsentModeIfEnabled(usercentricsReadyStatus.consents);
|
|
1056
|
+
this.clearSessionSuccessCallback?.Invoke(usercentricsReadyStatus);
|
|
1057
|
+
this.clearSessionSuccessCallback = null;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
internal void HandleClearError(string errorMessage)
|
|
1061
|
+
{
|
|
1062
|
+
logDebug("HandleClearError errorMessage=" + errorMessage);
|
|
1063
|
+
this.clearSessionErrorCallback?.Invoke(errorMessage);
|
|
1064
|
+
this.clearSessionErrorCallback = null;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
internal void HandleLoginClicked(string loginUrl)
|
|
1068
|
+
{
|
|
1069
|
+
logDebug("HandleLoginClicked loginUrl=" + loginUrl);
|
|
1070
|
+
this.onLoginClickedCallback?.Invoke(string.IsNullOrEmpty(loginUrl) ? null : loginUrl);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
internal void HandleSubscribeClicked(string subscribeUrl)
|
|
1074
|
+
{
|
|
1075
|
+
logDebug("HandleSubscribeClicked subscribeUrl=" + subscribeUrl);
|
|
1076
|
+
this.onSubscribeClickedCallback?.Invoke(string.IsNullOrEmpty(subscribeUrl) ? null : subscribeUrl);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
internal void HandleNotifyLoginSuccess(string _)
|
|
1080
|
+
{
|
|
1081
|
+
logDebug("HandleNotifyLoginSuccess");
|
|
1082
|
+
this.notifyLoginSuccessCallback?.Invoke();
|
|
1083
|
+
this.notifyLoginSuccessCallback = null;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
internal void HandleNotifyLoginError(string errorMessage)
|
|
1087
|
+
{
|
|
1088
|
+
logDebug("HandleNotifyLoginError errorMessage=" + errorMessage);
|
|
1089
|
+
this.notifyLoginErrorCallback?.Invoke(errorMessage);
|
|
1090
|
+
this.notifyLoginErrorCallback = null;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
internal void HandleNotifySubscribeSuccess(string _)
|
|
1094
|
+
{
|
|
1095
|
+
logDebug("HandleNotifySubscribeSuccess");
|
|
1096
|
+
this.notifySubscribeSuccessCallback?.Invoke();
|
|
1097
|
+
this.notifySubscribeSuccessCallback = null;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
internal void HandleNotifySubscribeError(string errorMessage)
|
|
1101
|
+
{
|
|
1102
|
+
logDebug("HandleNotifySubscribeError errorMessage=" + errorMessage);
|
|
1103
|
+
this.notifySubscribeErrorCallback?.Invoke(errorMessage);
|
|
1104
|
+
this.notifySubscribeErrorCallback = null;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
internal void HandleNotifySubscriptionLapsedSuccess(string _)
|
|
1108
|
+
{
|
|
1109
|
+
logDebug("HandleNotifySubscriptionLapsedSuccess");
|
|
1110
|
+
this.notifySubscriptionLapsedSuccessCallback?.Invoke();
|
|
1111
|
+
this.notifySubscriptionLapsedSuccessCallback = null;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
internal void HandleNotifySubscriptionLapsedError(string errorMessage)
|
|
1115
|
+
{
|
|
1116
|
+
logDebug("HandleNotifySubscriptionLapsedError errorMessage=" + errorMessage);
|
|
1117
|
+
this.notifySubscriptionLapsedErrorCallback?.Invoke(errorMessage);
|
|
1118
|
+
this.notifySubscriptionLapsedErrorCallback = null;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
internal void HandleChangeLanguageSuccess(string _)
|
|
1122
|
+
{
|
|
1123
|
+
logDebug("HandleChangeLanguageSuccess");
|
|
1124
|
+
this.changeLanguageSuccessCallback?.Invoke();
|
|
1125
|
+
this.changeLanguageSuccessCallback = null;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
internal void HandleChangeLanguageError(string errorMessage)
|
|
1129
|
+
{
|
|
1130
|
+
logDebug("HandleChangeLanguageError errorMessage=" + errorMessage);
|
|
1131
|
+
this.changeLanguageErrorCallback?.Invoke(errorMessage);
|
|
1132
|
+
this.changeLanguageErrorCallback = null;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
internal void HandleSetAgeSignalSuccess(string rawAgeSignalDecision)
|
|
1136
|
+
{
|
|
1137
|
+
// The payload is not logged, unlike the other handlers: it carries the age range
|
|
1138
|
+
logDebug("HandleSetAgeSignalSuccess");
|
|
1139
|
+
var decision = JsonUtility.FromJson<UsercentricsAgeSignalDecision>(rawAgeSignalDecision);
|
|
1140
|
+
// Cleared BEFORE the call: a host that calls SetAgeSignal again from inside its callback (a retry) stores new
|
|
1141
|
+
// callbacks, and clearing after the call would wipe them
|
|
1142
|
+
var callback = this.setAgeSignalSuccessCallback;
|
|
1143
|
+
this.setAgeSignalSuccessCallback = null;
|
|
1144
|
+
callback?.Invoke(decision);
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
internal void HandleSetAgeSignalError(string errorMessage)
|
|
1148
|
+
{
|
|
1149
|
+
// The message is not logged either: the callback gets it, and nothing here has to repeat it
|
|
1150
|
+
logDebug("HandleSetAgeSignalError");
|
|
1151
|
+
// Cleared before the call, like the success handler: a retry made from inside the callback must keep its callbacks
|
|
1152
|
+
var callback = this.setAgeSignalErrorCallback;
|
|
1153
|
+
this.setAgeSignalErrorCallback = null;
|
|
1154
|
+
callback?.Invoke(errorMessage);
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
#pragma warning restore IDE0051 // Remove unused private members
|
|
1158
|
+
#endregion
|
|
1159
|
+
}
|
|
1160
|
+
}
|