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.
Files changed (108) hide show
  1. package/Documentation/LICENSE +2 -0
  2. package/Documentation/LICENSE.meta +7 -0
  3. package/Documentation/README +169 -0
  4. package/Documentation/README.meta +7 -0
  5. package/Documentation.meta +8 -0
  6. package/Editor/ATTLocalizationMessageDrawer.cs +92 -0
  7. package/Editor/ATTLocalizationMessageDrawer.cs.meta +11 -0
  8. package/Editor/AssemblyInfo.cs +4 -0
  9. package/Editor/AssemblyInfo.cs.meta +11 -0
  10. package/Editor/Unity.UsercentricsEditor.asmdef +18 -0
  11. package/Editor/Unity.UsercentricsEditor.asmdef.meta +7 -0
  12. package/Editor/UsercentricsATTPostProcessor.cs +125 -0
  13. package/Editor/UsercentricsATTPostProcessor.cs.meta +11 -0
  14. package/Editor/UsercentricsAndroidPostBuild.cs +45 -0
  15. package/Editor/UsercentricsAndroidPostBuild.cs.meta +11 -0
  16. package/Editor/UsercentricsAndroidSdkCheck.cs +29 -0
  17. package/Editor/UsercentricsAndroidSdkCheck.cs.meta +11 -0
  18. package/Editor/UsercentricsDependencies.xml +18 -0
  19. package/Editor/UsercentricsDependencies.xml.meta +7 -0
  20. package/Editor/UsercentricsExternalDependencyManagerBuildCheck.cs +56 -0
  21. package/Editor/UsercentricsExternalDependencyManagerBuildCheck.cs.meta +11 -0
  22. package/Editor/UsercentricsExternalDependencyManagerCheck.cs +34 -0
  23. package/Editor/UsercentricsExternalDependencyManagerCheck.cs.meta +11 -0
  24. package/Editor/UsercentricsIOSBuildFixes.cs +171 -0
  25. package/Editor/UsercentricsIOSBuildFixes.cs.meta +11 -0
  26. package/Editor/UsercentricsPBXProjectExtensions.cs +281 -0
  27. package/Editor/UsercentricsPBXProjectExtensions.cs.meta +11 -0
  28. package/Editor/UsercentricsPodfilePatches.cs +116 -0
  29. package/Editor/UsercentricsPodfilePatches.cs.meta +11 -0
  30. package/Editor/UsercentricsSentryExcludePostBuild.cs +77 -0
  31. package/Editor/UsercentricsSentryExcludePostBuild.cs.meta +11 -0
  32. package/Editor/UsercentricsSentryGradleExclude.cs +189 -0
  33. package/Editor/UsercentricsSentryGradleExclude.cs.meta +11 -0
  34. package/Editor/UsercentricsWelcomeDialog.cs +76 -0
  35. package/Editor/UsercentricsWelcomeDialog.cs.meta +11 -0
  36. package/Editor.meta +8 -0
  37. package/Prefabs/ATTManager.prefab +47 -0
  38. package/Prefabs/ATTManager.prefab.meta +7 -0
  39. package/Prefabs/Usercentrics.prefab +74 -0
  40. package/Prefabs/Usercentrics.prefab.meta +7 -0
  41. package/Prefabs.meta +8 -0
  42. package/Scripts/AppTrackingTransparency/AppTrackingTransparencyManager.cs +59 -0
  43. package/Scripts/AppTrackingTransparency/AppTrackingTransparencyManager.cs.meta +11 -0
  44. package/Scripts/AppTrackingTransparency/Model/ATTLocalizationMessage.cs +15 -0
  45. package/Scripts/AppTrackingTransparency/Model/ATTLocalizationMessage.cs.meta +11 -0
  46. package/Scripts/AppTrackingTransparency/Model/AuthorizationStatus.cs +10 -0
  47. package/Scripts/AppTrackingTransparency/Model/AuthorizationStatus.cs.meta +11 -0
  48. package/Scripts/AppTrackingTransparency/Model/Language.cs +136 -0
  49. package/Scripts/AppTrackingTransparency/Model/Language.cs.meta +11 -0
  50. package/Scripts/AppTrackingTransparency/Model.meta +8 -0
  51. package/Scripts/AppTrackingTransparency.cs +60 -0
  52. package/Scripts/AppTrackingTransparency.cs.meta +11 -0
  53. package/Scripts/AppTrackingTransparency.meta +8 -0
  54. package/Scripts/Internal/AssemblyInfo.cs +3 -0
  55. package/Scripts/Internal/AssemblyInfo.cs.meta +11 -0
  56. package/Scripts/Internal/AutoInitialize.cs +42 -0
  57. package/Scripts/Internal/AutoInitialize.cs.meta +11 -0
  58. package/Scripts/Internal/BannerSettings.cs +165 -0
  59. package/Scripts/Internal/BannerSettings.cs.meta +11 -0
  60. package/Scripts/Internal/ConsentUpdateSubscriptionCoordinator.cs +42 -0
  61. package/Scripts/Internal/ConsentUpdateSubscriptionCoordinator.cs.meta +11 -0
  62. package/Scripts/Internal/Data.cs +960 -0
  63. package/Scripts/Internal/Data.cs.meta +11 -0
  64. package/Scripts/Internal/Errors.cs +22 -0
  65. package/Scripts/Internal/Errors.cs.meta +11 -0
  66. package/Scripts/Internal/FirstLayerStyleSettings.cs +248 -0
  67. package/Scripts/Internal/FirstLayerStyleSettings.cs.meta +11 -0
  68. package/Scripts/Internal/IUsercentrics.cs +45 -0
  69. package/Scripts/Internal/IUsercentrics.cs.meta +11 -0
  70. package/Scripts/Internal/InspectorLink.cs +27 -0
  71. package/Scripts/Internal/InspectorLink.cs.meta +11 -0
  72. package/Scripts/Internal/Singleton.cs +68 -0
  73. package/Scripts/Internal/Singleton.cs.meta +11 -0
  74. package/Scripts/Internal/StringParser.cs +41 -0
  75. package/Scripts/Internal/StringParser.cs.meta +11 -0
  76. package/Scripts/Internal/UCConstants.cs +13 -0
  77. package/Scripts/Internal/UCConstants.cs.meta +11 -0
  78. package/Scripts/Internal/UnityConsentModeAdapter.cs +78 -0
  79. package/Scripts/Internal/UnityConsentModeAdapter.cs.meta +11 -0
  80. package/Scripts/Internal/UsercentricsAndroid.cs +210 -0
  81. package/Scripts/Internal/UsercentricsAndroid.cs.meta +11 -0
  82. package/Scripts/Internal/UsercentricsIOS.cs +307 -0
  83. package/Scripts/Internal/UsercentricsIOS.cs.meta +11 -0
  84. package/Scripts/Internal.meta +8 -0
  85. package/Scripts/Unity.Usercentrics.asmdef +14 -0
  86. package/Scripts/Unity.Usercentrics.asmdef.meta +7 -0
  87. package/Scripts/Usercentrics.cs +1160 -0
  88. package/Scripts/Usercentrics.cs.meta +11 -0
  89. package/Scripts.meta +8 -0
  90. package/UsercentricsInstallGuard/Usercentrics.InstallGuard.Static.asmdef +16 -0
  91. package/UsercentricsInstallGuard/Usercentrics.InstallGuard.Static.asmdef.meta +7 -0
  92. package/UsercentricsInstallGuard/UsercentricsInstallGuard.cs +82 -0
  93. package/UsercentricsInstallGuard/UsercentricsInstallGuard.cs.meta +11 -0
  94. package/UsercentricsInstallGuard.meta +8 -0
  95. package/iOS/TrackingTransparencyManager.h +13 -0
  96. package/iOS/TrackingTransparencyManager.h.meta +27 -0
  97. package/iOS/TrackingTransparencyManager.mm +99 -0
  98. package/iOS/TrackingTransparencyManager.mm.meta +37 -0
  99. package/iOS/Usercentrics.mm +228 -0
  100. package/iOS/Usercentrics.mm.meta +37 -0
  101. package/iOS/UsercentricsATTManager.mm +21 -0
  102. package/iOS/UsercentricsATTManager.mm.meta +37 -0
  103. package/iOS.meta +8 -0
  104. package/link.xml +24 -0
  105. package/link.xml.meta +7 -0
  106. package/package.json +10 -4
  107. package/package.json.meta +7 -0
  108. package/README.md +0 -3
@@ -0,0 +1,2 @@
1
+ Copyright 2024 Usercentrics.
2
+ All rights reserved.
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: e6171e07028954933b89d6b2b6dae852
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,169 @@
1
+ Usercentrics Unity SDK - 2.36.0
2
+
3
+ The purpose of the Usercentrics Unity SDK is to provide a lightweight and flexible library for the integration of a Consent Management Platform (CMP) into native mobile applications, to enable the collection, storage and management of your user's consent, in order to ensure legal compliance for different legal frameworks.
4
+
5
+ - Getting Started
6
+ Follow our Documentation (https://usercentrics.com/docs/install) to get started with your CMP integration.
7
+
8
+ - Getting an account
9
+ You will need an account to configure and initialize the SDK. See Pricing Packages (https://usercentrics.com/pricing/unity).
10
+
11
+ - Moving between the .unitypackage and the UPM package
12
+ See Migrating to the Unity Package Manager (https://usercentrics.com/docs/unity-migrate-to-upm).
13
+ It covers migrating either way, switching between the normal and the static package, installing without a
14
+ registry, and the failures that are easy to miss because nothing is logged.
15
+
16
+
17
+ ---
18
+
19
+ Managed Code Stripping
20
+ -----------------------
21
+
22
+ The SDK is compatible with all Unity managed code stripping levels: Minimal, Low, Medium, and High.
23
+
24
+ A link.xml file is included and preserves the Unity.Usercentrics assembly from IL2CPP/Mono
25
+ stripping automatically — no configuration is required, installing the SDK is enough. Where it
26
+ lands depends on how you installed:
27
+ - .unitypackage: Assets/Usercentrics/link.xml
28
+ - UPM package: Packages/com.usercentrics.sdk/link.xml
29
+ Packages/com.usercentrics.sdk.static/link.xml for the static variant
30
+
31
+ If your project has its own link.xml, Unity merges multiple link.xml files automatically.
32
+
33
+
34
+ ---
35
+
36
+ External Dependency Manager
37
+ ---------------------------
38
+
39
+ The UPM packages (com.usercentrics.sdk and com.usercentrics.sdk.static) do not include the External Dependency
40
+ Manager for Unity (EDM4U). EDM4U resolves the native Android (Gradle) and iOS (CocoaPods or Swift Package Manager)
41
+ dependencies listed in Editor/UsercentricsDependencies.xml, so your project needs its own copy.
42
+ The .unitypackage files already contain it.
43
+
44
+ On Unity 2019.1 and newer, install it from OpenUPM (scoped registry https://package.openupm.com, scope
45
+ com.google.external-dependency-manager). Unity 2018.4 has no scoped registries: import the .unitypackage from
46
+ https://github.com/googlesamples/unity-jar-resolver instead.
47
+
48
+ If it is missing, an Android or iOS build logs a warning in the Console that names the missing resolver
49
+ (Google.JarResolver or Google.IOSResolver). The build still succeeds, but the app fails at runtime (on Android with
50
+ a ClassNotFoundException for com.usercentrics.sdk.unity.UsercentricsUnity). The warning is a false alarm if you add
51
+ the native dependencies yourself.
52
+
53
+ The warning only detects a missing External Dependency Manager. A resolver that was just imported and not yet enabled by
54
+ its Version Handler counts as missing, so let the import finish before you build. A misconfigured one is not detected,
55
+ for example EDM4U 1.2.120 with "Patch mainTemplate.gradle" off (see below).
56
+
57
+ Tested with EDM4U 1.2.187. EDM4U 1.2.120 also works with these settings:
58
+ - Assets > External Dependency Manager > Android Resolver > Settings: tick "Patch mainTemplate.gradle" (it is off by
59
+ default in 1.2.120) and use a custom main Gradle template. Without it the resolver copies about 70 libraries into
60
+ Assets and Gradle fails on a duplicate Kotlin module.
61
+ - Run Unity with a JDK 11 as JAVA_HOME: the 1.2.120 resolver does not work with JDK 21.
62
+
63
+ The first "Force Resolve" in a project that does not have an Assets/Plugins/Android folder yet fails and
64
+ resolves nothing:
65
+
66
+ Unable to copy 'mainTemplate.gradle' from Unity engine folder '...' to this project folder
67
+ 'Assets/Plugins/Android'.
68
+ System.IO.DirectoryNotFoundException: .../Assets/Plugins/Android/mainTemplate.gradle
69
+ at GooglePlayServices.GradleTemplateResolver.EnsureGradleTemplateEnabled (...)
70
+ Resolution Failed.
71
+
72
+ EDM4U wants to enable the custom main Gradle template but does not create the folder it goes in. It does create
73
+ the folder on the way out, so running Force Resolve a second time succeeds and the Usercentrics dependencies are
74
+ written into Assets/Plugins/Android/mainTemplate.gradle. Seen with EDM4U 1.2.187 on Unity 6000.3 at its own
75
+ default settings, in a project created from scratch — which a UPM install often is. This is an EDM4U issue, not a
76
+ Usercentrics one; run Force Resolve again and continue.
77
+
78
+ iOS on Unity older than 2021.3 (2018.4 to 2020.3): Swift Package Manager is not supported there, but EDM4U 1.2.187
79
+ still drops the CocoaPods entry for UsercentricsUI while it is enabled (the default), so the iOS project ends up
80
+ without UsercentricsUI. Turn off Swift Package Manager in Assets > External Dependency Manager > iOS Resolver >
81
+ Settings and the pod is added again.
82
+
83
+ On Unity 2021.3 and newer a new project uses Swift Package Manager by default. The generated Podfile then has no
84
+ UsercentricsUI entry, which is expected: the package is added to the Xcode project instead.
85
+
86
+
87
+ ---
88
+
89
+ Static linkage package and Unity versions
90
+ -----------------------------------------
91
+
92
+ The normal package supports Unity 2018.4 and newer.
93
+
94
+ The static linkage package (com.usercentrics.sdk.static, or the .unitypackage with "static" in its name) needs
95
+ Unity 2019.3 or newer for iOS builds. It uses the UnityFramework target, which Unity only exports from 2019.3, so on
96
+ older versions the iOS build fails in Xcode. Use the normal package there. Android builds are not affected.
97
+
98
+ Package Manager does not block a tarball install on an older Unity version. The static package logs a warning
99
+ in the Console instead.
100
+
101
+
102
+ ---
103
+
104
+ Testing Consent Mediation (Firebase)
105
+ --------------------------------------
106
+
107
+ The sample app supports a Firebase Analytics integration to test the consent mediation workflow
108
+ on both iOS and Android.
109
+
110
+ Prerequisites:
111
+ - iOS: add GoogleService-Info.plist at Assets/GoogleService-Info.plist
112
+ - Android: add google-services.json at Assets/google-services.json
113
+
114
+ Steps:
115
+
116
+ 1. The demo is part of the sample project in the SDK repository
117
+ (SampleProject-2019.4/Assets/Usercentrics/Demo/DemoScript.cs); neither the .unitypackage
118
+ nor the UPM packages ship it. Open it there and ensure the flag is set:
119
+ private const bool CONSENT_MEDIATION_ENABLED = true;
120
+
121
+ 2. Build and run the sample app on iOS or Android.
122
+
123
+ 3. Tap "Show First Layer" — the Usercentrics consent banner will appear.
124
+
125
+ 4. Accept or deny consent.
126
+
127
+ 5. Check the device logs (Logcat on Android / Xcode console on iOS) for:
128
+ [UC_DEMO] OnConsentMediation fired. sdks=<count>
129
+ [UC_DEMO] SDK: <name> consent=<true/false> mediated=<true/false>
130
+
131
+ 6. Verify that Firebase Analytics appears in the mediated SDK list with the expected consent value.
132
+
133
+ Notes:
134
+ - To disable mediation testing and revert to the standard flow, set CONSENT_MEDIATION_ENABLED = false.
135
+
136
+
137
+ ---
138
+
139
+ Android build requirements on Unity 2018.4 and 2019.4
140
+ -----------------------------------------------------
141
+
142
+ Since 2.21.1 the Usercentrics Android library is compiled for Java 11 (it was Java 8 before).
143
+ The Gradle toolchain bundled with Unity 2018.4 and 2019.4 (Android Gradle Plugin 3.4.0,
144
+ Gradle 5.1.1, JDK 8) cannot build it, and the Android build fails in Gradle.
145
+ You need Android Gradle Plugin 4.2.2, Gradle 6.7.1, a JDK 11 for Gradle, AndroidX and no Jetifier,
146
+ plus the Android SDK platform 33 or higher installed. This is the compileSdk the Android libraries of SDK 2.33.1 require (their AndroidX dependencies state it; the build stops in Gradle with "minCompileSdk (33) ... is greater than this module's compileSdkVersion" otherwise) and may rise in later versions. They also need minSdk 21 (the Unity 2018.4 to 2020.3 default is 19, raise it in Player Settings).
147
+
148
+ Unity 2019.4
149
+ - baseProjectTemplate.gradle (custom template): set `classpath 'com.android.tools.build:gradle:4.2.2'`
150
+ - gradleTemplate.properties (custom template): add `android.useAndroidX=true` and `org.gradle.java.home=<path to a JDK 11>`
151
+ - Edit > Preferences > External Tools: uncheck "Gradle Installed with Unity (recommended)" and select Gradle 6.7.1.
152
+ Leave the JDK on the one installed with Unity: Unity 2019.4 only accepts JDK 8 there, and Gradle uses the JDK 11 from `org.gradle.java.home`
153
+ - Assets > External Dependency Manager > Android Resolver > Settings: uncheck "Use Jetifier"
154
+ - Player Settings > Other Settings > Target API Level: Automatic (highest installed, with platform 33 or higher installed), or a fixed 33 or higher
155
+
156
+ Unity 2018.4
157
+ The two templates above do not exist in 2018.4, so the build has to leave the Editor:
158
+ - Assets > External Dependency Manager > Android Resolver > Settings: uncheck "Use Jetifier"
159
+ - Player Settings > Other Settings > Target API Level: a fixed value below 31, for example 29 (not Automatic, which picks the highest
160
+ installed platform). The 2018.4 manifest does not declare `android:exported`, which Android 12 and higher require.
161
+ Set `compileSdkVersion` to 33 or higher in your custom mainTemplate.gradle
162
+ - Build Settings > Android: tick "Export Project" and export
163
+ - In the exported project: change the AGP classpath in build.gradle to `com.android.tools.build:gradle:4.2.2`
164
+ and add `android.useAndroidX=true` to gradle.properties
165
+ - Build the exported project with Gradle 6.7.1 on JDK 11 (`gradle assembleRelease`, or Android Studio)
166
+
167
+ Verified with the Usercentrics sample: on Unity 2019.4.41f2 the Editor build, run on an arm64 Android 14 emulator (the first layer shows),
168
+ and on Unity 2018.4.36f1 the exported project built with Gradle (not run on a device).
169
+ Unity 6000.3 builds with its default toolchain. On Unity 2020.3 an IL2CPP build with the External Dependency Manager works with a fixed Target API Level (Automatic can pick a level whose aapt2 fails) and minSdk 21; the first layer shows on an arm64 Android 14 emulator.
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: cfa3da5d481a041508803c43ce3806b5
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 7cf005c8c132a4eb49c11414bc178efb
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,92 @@
1
+ using UnityEditor;
2
+ using UnityEngine;
3
+
4
+ namespace Unity.Usercentrics
5
+ {
6
+
7
+ [CustomPropertyDrawer(typeof(ATTLocalizationMessage))]
8
+ public class ATTLocalizationMessageDrawer : PropertyDrawer
9
+ {
10
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
11
+ {
12
+ EditorGUI.BeginProperty(position, label, property);
13
+
14
+ Rect languageRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
15
+ Rect messageRect = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing, position.width, EditorGUIUtility.singleLineHeight);
16
+
17
+ SerializedProperty languageProperty = property.FindPropertyRelative("Language");
18
+ SerializedProperty messageProperty = property.FindPropertyRelative("PopupMessage");
19
+ SerializedProperty manualIsoCodeProperty = property.FindPropertyRelative("ManualIsoCode");
20
+
21
+ EditorGUI.PropertyField(languageRect, languageProperty, GUIContent.none);
22
+
23
+ Language selectedLanguage = (Language) languageProperty.enumValueIndex;
24
+
25
+ if (isOtherLanguageSelected(selectedLanguage))
26
+ {
27
+ Rect manualIsoCodeRect = new Rect(position.x, position.y + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) * 2, position.width, EditorGUIUtility.singleLineHeight);
28
+ EditorGUI.PropertyField(manualIsoCodeRect, manualIsoCodeProperty, new GUIContent("Manual ISO Code"));
29
+ }
30
+
31
+ EditorGUI.PropertyField(messageRect, messageProperty);
32
+
33
+ EditorGUI.EndProperty();
34
+
35
+ Rect removeButtonRect = new Rect(position.x, position.y + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) * 3, position.width, EditorGUIUtility.singleLineHeight);
36
+ if (GUI.Button(removeButtonRect, "Remove"))
37
+ {
38
+ RemoveLocalizationMessage(property);
39
+ }
40
+ }
41
+
42
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
43
+ {
44
+ int numRectangles = 3; // Language, ManualIsoCode and Remove buttons
45
+
46
+ SerializedProperty languageProperty = property.FindPropertyRelative("Language");
47
+ Language selectedLanguage = (Language)languageProperty.enumValueIndex;
48
+
49
+ if (isOtherLanguageSelected(selectedLanguage))
50
+ {
51
+ numRectangles++;
52
+ }
53
+
54
+ float lineHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
55
+ return (numRectangles + 1) * lineHeight;
56
+ }
57
+
58
+ private bool isOtherLanguageSelected(Language selectedLanguage)
59
+ {
60
+ return selectedLanguage == Language.Other;
61
+ }
62
+
63
+ private void RemoveLocalizationMessage(SerializedProperty property)
64
+ {
65
+ SerializedObject serializedObject = property.serializedObject;
66
+ SerializedProperty localizationMessagesProperty = serializedObject.FindProperty("LocalizationMessages");
67
+
68
+ int arrayIndex = GetArrayIndexFromPropertyPath(property);
69
+ if (arrayIndex >= 0 && arrayIndex < localizationMessagesProperty.arraySize)
70
+ {
71
+ localizationMessagesProperty.DeleteArrayElementAtIndex(arrayIndex);
72
+ serializedObject.ApplyModifiedProperties();
73
+ }
74
+ }
75
+
76
+ private int GetArrayIndexFromPropertyPath(SerializedProperty property)
77
+ {
78
+ string propertyPath = property.propertyPath;
79
+ int startIndex = propertyPath.IndexOf('[') + 1;
80
+ int endIndex = propertyPath.IndexOf(']');
81
+ string indexStr = propertyPath.Substring(startIndex, endIndex - startIndex);
82
+
83
+ int index;
84
+ if (int.TryParse(indexStr, out index))
85
+ {
86
+ return index;
87
+ }
88
+ return -1;
89
+ }
90
+ }
91
+
92
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 0ed9e493099ab44d38d9ac70c7720fd2
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,4 @@
1
+ using System.Runtime.CompilerServices;
2
+
3
+ // Lets the EditMode tests (Unity.Usercentrics.Tests) reach the internal classes of this assembly
4
+ [assembly: InternalsVisibleTo("Unity.Usercentrics.Tests")]
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 46c04d703298423d8029d9d16ca32d79
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "Unity.UsercentricsEditor",
3
+ "rootNamespace": "",
4
+ "references": [
5
+ "Unity.Usercentrics"
6
+ ],
7
+ "includePlatforms": [
8
+ "Editor"
9
+ ],
10
+ "excludePlatforms": [],
11
+ "allowUnsafeCode": false,
12
+ "overrideReferences": false,
13
+ "precompiledReferences": [],
14
+ "autoReferenced": true,
15
+ "defineConstraints": [],
16
+ "versionDefines": [],
17
+ "noEngineReferences": false
18
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 00520d9db203f4e24bfcd75745228254
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,125 @@
1
+ #if UNITY_IOS
2
+ using UnityEditor;
3
+ using UnityEditor.Callbacks;
4
+ using UnityEditor.iOS.Xcode;
5
+ using System.IO;
6
+ using System.Reflection;
7
+ using System.Collections.Generic;
8
+
9
+ namespace Unity.Usercentrics
10
+ {
11
+ public class ATTPostProcessor
12
+ {
13
+ private const string DefaultStringsPlistFileName = "InfoPlist.strings";
14
+ private const string InfoPlistFileName = "Info.plist";
15
+ private const string MessageKey = "NSUserTrackingUsageDescription";
16
+ private const string EnglishIsoCode = "en";
17
+
18
+ private string EnglishMessage;
19
+ private string BuildPath;
20
+ private string ProjectPath;
21
+ private PBXProject XcodeProject = new PBXProject();
22
+ private List<ATTLocalizationMessage> LocalizationMessages;
23
+
24
+ public ATTPostProcessor(string buildPath, string englishMessage)
25
+ {
26
+ this.BuildPath = buildPath;
27
+ this.EnglishMessage = englishMessage;
28
+ this.ProjectPath = PBXProject.GetPBXProjectPath(this.BuildPath);
29
+ this.XcodeProject.ReadFromFile(this.ProjectPath);
30
+ this.LocalizationMessages = AppTrackingTransparency.m_LocalizationMessages;
31
+ }
32
+
33
+ [PostProcessBuild]
34
+ public static void UpdatePlistFile(BuildTarget buildTarget, string buildPath)
35
+ {
36
+ var englishMessage = AppTrackingTransparency.m_EnglishDefaultMessage;
37
+ var isEnabled = englishMessage != null && englishMessage.Trim().Length != 0;
38
+ if (!isEnabled)
39
+ {
40
+ return;
41
+ }
42
+
43
+ new ATTPostProcessor(buildPath, englishMessage).Run();
44
+ }
45
+
46
+ private void Run()
47
+ {
48
+ WriteDefaultMessageToRootInfoPlist();
49
+ CreateLanguagesLocalizations();
50
+ }
51
+
52
+ private void WriteDefaultMessageToRootInfoPlist()
53
+ {
54
+ var plistPath = Path.Combine(this.BuildPath, ATTPostProcessor.InfoPlistFileName);
55
+
56
+ var plist = new PlistDocument();
57
+ plist.ReadFromFile(plistPath);
58
+
59
+ PlistElementDict rootDict = plist.root;
60
+ rootDict.SetString(ATTPostProcessor.MessageKey, this.EnglishMessage);
61
+
62
+ File.WriteAllText(plistPath, plist.WriteToString());
63
+ }
64
+
65
+ private void CreateLocalization(string isoCode, string message)
66
+ {
67
+ if (message == null || message.Trim().Length == 0)
68
+ {
69
+ return;
70
+ }
71
+
72
+ var languageDirectoryName = string.Format("{0}.lproj", isoCode);
73
+
74
+ string languageDirectoryPath = Path.Combine(this.BuildPath, languageDirectoryName);
75
+ Directory.CreateDirectory(languageDirectoryPath);
76
+
77
+ string stringsPlistFilePath = Path.Combine(languageDirectoryPath, ATTPostProcessor.DefaultStringsPlistFileName);
78
+ File.WriteAllText(stringsPlistFilePath, $"\"{ATTPostProcessor.MessageKey}\" = \"{message}\";");
79
+
80
+ string stringsPlistContent = File.ReadAllText(stringsPlistFilePath);
81
+ File.WriteAllText(stringsPlistFilePath, stringsPlistContent);
82
+
83
+ string relativePath = Path.Combine(languageDirectoryName, ATTPostProcessor.DefaultStringsPlistFileName);
84
+ this.XcodeProject.AddLocaleVariantFile(ATTPostProcessor.DefaultStringsPlistFileName, isoCode, relativePath);
85
+
86
+ this.XcodeProject.WriteToFile(this.ProjectPath);
87
+ }
88
+
89
+ private void CreateLanguagesLocalizations()
90
+ {
91
+ CreateLocalization(ATTPostProcessor.EnglishIsoCode, this.EnglishMessage);
92
+
93
+ foreach (var localizationMessage in this.LocalizationMessages)
94
+ {
95
+ var language = localizationMessage.Language;
96
+ var popupMessage = localizationMessage.PopupMessage;
97
+ string isoCode;
98
+
99
+ if (language != Language.Other)
100
+ {
101
+ isoCode = GetIsoCode(language);
102
+ }
103
+ else
104
+ {
105
+ isoCode = localizationMessage.ManualIsoCode;
106
+ }
107
+
108
+ CreateLocalization(isoCode, popupMessage);
109
+ }
110
+ }
111
+
112
+ private string GetIsoCode(Language language)
113
+ {
114
+ FieldInfo fieldInfo = language.GetType().GetField(language.ToString());
115
+ IsoCodeAttribute[] attributes = fieldInfo.GetCustomAttributes(typeof(IsoCodeAttribute), false) as IsoCodeAttribute[];
116
+
117
+ if (attributes.Length > 0)
118
+ {
119
+ return attributes[0].Code;
120
+ }
121
+ return string.Empty;
122
+ }
123
+ }
124
+ }
125
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 163bd6ca5016140d8954f0f9de7e5217
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,45 @@
1
+ using System.IO;
2
+ using UnityEditor;
3
+ using UnityEditor.Android;
4
+ using UnityEditor.Build;
5
+ using UnityEngine;
6
+
7
+ namespace Unity.Usercentrics.Editor
8
+ {
9
+ public class UsercentricsAndroidPostBuild : IPostGenerateGradleAndroidProject
10
+ {
11
+ public int callbackOrder => 0;
12
+
13
+ public void OnPostGenerateGradleAndroidProject(string path)
14
+ {
15
+ // Unity's native plugin system copies Assets/Usercentrics/Plugins/usercentrics-android-*.aar
16
+ // directly into unityLibrary/libs/ and injects the implementation line via **DEPS**.
17
+ // No manual copy needed here.
18
+ string libsDir = Path.Combine(path, "libs");
19
+ if (!Directory.Exists(libsDir))
20
+ Directory.CreateDirectory(libsDir);
21
+
22
+ // When the External Dependency Manager fails to resolve the dependency (for example its Gradle crashing
23
+ // on the JDK that ships with Unity 6) the build still succeeds, but the app has no Usercentrics classes
24
+ // and only fails at runtime. Say so here, while the cause can still be found in the build log. The SDK can
25
+ // be wired in several ways (a patched Gradle template, AARs copied in by the resolver, another module), so
26
+ // the check only warns, and fails the build when UC_ANDROID_STRICT_SDK_CHECK=1 (the sample project does).
27
+ if (!UsercentricsAndroidSdkCheck.HasUsercentricsDependency(path))
28
+ {
29
+ const string message =
30
+ "Usercentrics: could not find the native Android SDK in the generated Gradle project (looked for 'com.usercentrics.sdk' " +
31
+ "in build.gradle and for a file with 'usercentrics' in its name in libs/). If the SDK is really missing, the app fails at " +
32
+ "startup with a ClassNotFoundException for 'com.usercentrics.sdk.unity.UsercentricsUnity'. A common cause is that the " +
33
+ "External Dependency Manager could not write the dependency because the folder 'Assets/Plugins/Android' does not exist " +
34
+ "(look earlier in this log for \"Unable to copy 'mainTemplate.gradle'\"). To fix it, run Assets > External Dependency Manager > " +
35
+ "Android Resolver > Force Resolve again (the failed run creates the folder) or create 'Assets/Plugins/Android' yourself, " +
36
+ "make sure Force Resolve finishes without errors, and build again. " +
37
+ "This can be a false alarm when the SDK is added in another way, for example through a different Gradle module. " +
38
+ "Set UC_ANDROID_STRICT_SDK_CHECK=1 to fail the build instead.";
39
+ if (System.Environment.GetEnvironmentVariable("UC_ANDROID_STRICT_SDK_CHECK") == "1")
40
+ throw new BuildFailedException(message);
41
+ Debug.LogWarning(message);
42
+ }
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 1c944d07fc87e4d20a80d2c604d0f9f5
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,29 @@
1
+ using System;
2
+ using System.IO;
3
+
4
+ namespace Unity.Usercentrics.Editor
5
+ {
6
+ // Looks for the native Android SDK in a generated Gradle project, however it got there: a dependency line in
7
+ // build.gradle ("com.usercentrics.sdk:usercentrics-ui:x" or implementation(name: 'com.usercentrics.sdk.usercentrics-ui-x', ext:'aar')),
8
+ // or a file copied into libs/ (the resolver's copy mode names it com.usercentrics.sdk.usercentrics-ui-x.aar).
9
+ internal static class UsercentricsAndroidSdkCheck
10
+ {
11
+ internal static bool HasUsercentricsDependency(string gradleProjectPath)
12
+ {
13
+ string gradleFile = Path.Combine(gradleProjectPath, "build.gradle");
14
+ if (File.Exists(gradleFile) &&
15
+ File.ReadAllText(gradleFile).IndexOf("com.usercentrics.sdk", StringComparison.OrdinalIgnoreCase) >= 0)
16
+ return true;
17
+
18
+ string libsDir = Path.Combine(gradleProjectPath, "libs");
19
+ if (!Directory.Exists(libsDir)) return false;
20
+
21
+ foreach (string file in Directory.GetFiles(libsDir))
22
+ {
23
+ if (Path.GetFileName(file).IndexOf("usercentrics", StringComparison.OrdinalIgnoreCase) >= 0)
24
+ return true;
25
+ }
26
+ return false;
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: b4fa599258774218945bbb3e0b762a82
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,18 @@
1
+ <dependencies>
2
+ <androidPackages>
3
+ <androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib-jdk8:[1.9.23]" />
4
+ <androidPackage spec="com.usercentrics.sdk:usercentrics-ui:[2.36.0]" />
5
+ </androidPackages>
6
+
7
+ <remoteSwiftPackage url="https://bitbucket.org/usercentricscode/usercentrics-spm-ui.git"
8
+ version="2.36.0-unity-static">
9
+ <swiftPackage name="UsercentricsUI" replacesPod="UsercentricsUI" />
10
+ </remoteSwiftPackage>
11
+
12
+ <iosPods>
13
+ <sources>
14
+ <source>https://bitbucket.org/usercentricscode/usercentrics-ios-specification.git</source>
15
+ </sources>
16
+ <iosPod name="UsercentricsUI" version="2.36.0-unity-static" />
17
+ </iosPods>
18
+ </dependencies>
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 6bce00777e9194d5094d965f7cf8c0c9
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant: