You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+45-25Lines changed: 45 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,22 @@
1
1
# Unity-SDK
2
-
Your plug & play CMP for Unity.
3
2
4
-
<mark>**Note**: Sourcepoint's Unity SDK can be used for both Android OS and iOS. Sourcepoint's Unity SDK can be integrated with both Android and iOS. Since it embeds native SDKs, and those only work in their respective platforms, the Unity SDK can't be demoed using Unity's Editor.
3
+
Sourcepoint's plug and play Unity SDK can be integrated with both Android and iOS.
5
4
6
-
<mark>**Note**: Sourcepoint's Unity SDK uses ExternalDependencyManager by Google https://github.com/googlesamples/unity-jar-resolver in order to fetch native SDKs and their dependencies. Make sure you resolve all the dependencies mentioned in `Assets/ExternalDependencyManager/Editor/SourcepointDependencies.xml` before building your application.
5
+
> **Note**: The Unity SDK can not be demoed using Unity's Editor since it embeds native SDKs and those only work in their respective platforms.
6
+
> <br><br>Additionally, this SDK utilizes [ExternalDependencyManager by Google](https://github.com/googlesamples/unity-jar-resolver) in order to fetch native SDKs and their dependencies. Ensure all the dependencies mentioned in `Assets/ExternalDependencyManager/Editor/SourcepointDependencies.xml` are resolved before building your application.
7
+
8
+
---
7
9
8
10
# Instantiate consent UI
9
11
10
12
To start, include the following library namepsace in your script:
13
+
11
14
```c#
12
15
usingConsentManagementProviderLib;
13
16
```
14
17
15
-
1. Construct `List<SpCampaign>` which contains `SpCampaign` objects. Each `SpCampaign` object should consist of `CAMPAIGN_TYPE` along with `TargetingParams` you need.
18
+
Construct `List<SpCampaign>` which contains `SpCampaign` objects. Each `SpCampaign` object should consist of `CAMPAIGN_TYPE` along with the `TargetingParams` you need.
@@ -29,7 +33,8 @@ using ConsentManagementProviderLib;
29
33
spCampaigns.Add(ios14);
30
34
```
31
35
32
-
2. In order to instantiate & trigger Consent Message Web View, you must call the `CMP.Initialize` function in `Awake` along with spCampaigns, accountId, propertyName and language.<br/> <br/>Additionally, you can also specify a `messageTimeout` which is set to **3 seconds** by default.
36
+
In order to instantiate & trigger `Consent Message Web View`, you must call the `CMP.Initialize` function in `Awake` along with `spCampaigns`, `accountId`, `propertyName` and `language`.<br/> <br/>Additionally, you can also specify a `messageTimeout` which, by default, is set to **30 seconds**.
37
+
33
38
```c#
34
39
CMP.Initialize(spCampaigns: spCampaigns,
35
40
accountId: 22,
@@ -39,16 +44,19 @@ using ConsentManagementProviderLib;
39
44
messageTimeoutInSeconds: 3);
40
45
```
41
46
42
-
<mark>**Note**: It may take a frame to initialize the CMP library, so we strongly recommend that you `Initialize` in `Awake` separately from `LoadMessage`. We recommend that you `LoadMessage` in `Start` (see example below).</mark>
47
+
> **Note**: It may take a frame to initialize the CMP library, so we strongly recommend that you `Initialize` in `Awake` separately from `LoadMessage`. We recommend that you `LoadMessage` in `Start` (see example below).
48
+
49
+
When the SDK receives the `LoadMessage` call, it will instantiate a webview if the end-user needs to see a message. <br/><br/> If there is a consent profile associated with `authId`, the SDK will bring the consent data from the server, overwriting whatever was stored in the device.
43
50
44
-
3. Right after the `LoadMessage` call, the SDK will construct the Web View for the end-user. <br/><br/> If there is a consent profile associated with authId "JohnDoe", the SDK will bring the consent data from the server, overwriting whatever was stored in the device.
45
51
```c#
46
52
privatevoidStart()
47
53
{
48
54
CMP.LoadMessage(authId: null); // or pass it a String if you wish to use authenticated consent
49
55
}
50
56
```
51
-
3. In order to free memory, call `Dispose` as illustrated in the following example :
57
+
58
+
In order to free memory, call `Dispose` as illustrated in the following example :
59
+
52
60
```c#
53
61
privatevoidOnDestroy()
54
62
{
@@ -60,15 +68,16 @@ private void OnDestroy()
60
68
61
69
Consent callbacks allow you to track progress and receive updates of user interaction. We provide the following interfaces:
|`IOnConsentUIReady`| Triggered when web view UI is ready and about to show |
74
+
|`IOnConsentAction`| Triggered when user made an action, provides you instance of enum `CONSENT_ACTION_TYPE`. See below for more information.|
75
+
|`IOnConsentError`| Triggered when something went wrong, provides you instance of Exception |
76
+
|`IOnConsentUIFinished`| Triggered when user interaction with web view UI is done and view is about to disappear |
77
+
|`IOnConsentReady`| Triggered when server successfully reacted to user's consent, provides you `SpConsent` object with consent info |
70
78
71
79
`CONSENT_ACTION_TYPE` can return the following:
80
+
72
81
```c#
73
82
publicenumCONSENT_ACTION_TYPE
74
83
{
@@ -82,9 +91,13 @@ public enum CONSENT_ACTION_TYPE
82
91
```
83
92
84
93
# Workflow to handle callbacks using interfaces
85
-
Once you created your own script which derives from `MonoBehaviour` and attached this component to your `GameObject` you should:
86
-
1. Inherit your script from any number of interfaces from the `IConsentEventHandler` list you are interested in and implement its method(s).<br/>
87
-
For example, suppose you want to handle Exception callback via `IOnConsentErrorEventHandler`, and you already implemented `IOnConsentErrorEventHandler` inheritance and `OnConsentError` method in your script and attached this script to generic `GameObject` in hierarchy. What's next?
94
+
95
+
After you have created your own script which derives from `MonoBehaviour` and attached this component to your `GameObject` you should perform the following:
96
+
97
+
Inherit your script from any number of interfaces from the `IConsentEventHandler` list you are interested in and implement its method(s).
98
+
99
+
> Example<br>Suppose you want to handle exception callback via `IOnConsentErrorEventHandler`, and you already implemented `IOnConsentErrorEventHandler` inheritance and `OnConsentError` method in your script and attached this script to generic `GameObject` in hierarchy. What's next?
@@ -94,24 +107,28 @@ public class ConsentEventHandler : MonoBehaviour, IOnConsentError
94
107
}
95
108
}
96
109
```
97
-
2. Register your `gameObject` (which implements any inheritor of `IConsentEventHandler` interface) as an event listener with `ConsentMessenger.AddListener` static method. It can be registered any time before you call the `LoadMessage` method (`Awake`, `Start` is enough, but you can adopt registration to your own logic).
110
+
111
+
Register your `gameObject` (which implements any inheritor of `IConsentEventHandler` interface) as an event listener with `ConsentMessenger.AddListener` static method. It can be registered any time before you call the `LoadMessage` method (`Awake`, `Start` is enough, but you can adopt the registration to your own logic).
112
+
113
+
> In the example below, we have added the current `gameObject` as listener for `IOnConsentError` events.<br><br>The event will be executed on all components of the game object that can handle it, regardless of whether they are subscribed or not if at least one have registered the `gameObject` as a listener.
⤤ Adds current `gameObject` as listener for `IOnConsentError` events ⤣<br/>
105
-
<mark>**Note**: The event will be executed on all components of the game object that can handle it, regardless of whether they are subscribed or not if at least one have registered the `gameObject` as a listener.</mark>
106
121
107
-
3. You should also unregister your listener when it becomes unnecessary due to garbage collection. `OnDestroy` is enough for our purposes:
122
+
You should also unregister your listener when it becomes unnecessary due to garbage collection. `OnDestroy` is enough for our purposes:
4. The solution is ready. Configure it and deploy!
130
+
131
+
The solution is ready. Configure it and deploy!
115
132
116
133
Both calling & handling workflows are implemented in the `ConsentMessageProvider` and `ConsentEventHandler` scripts of our example app accordingly. Feel free to use these components.
117
134
@@ -171,7 +188,8 @@ public class ConsentEventHandler : MonoBehaviour, IOnConsentUIReady, IOnConsentA
171
188
172
189
# Resurface Privacy Manager
173
190
174
-
Once a player has completed the consent flow, you may be interested to resurface your privacy manager so the player can see/manage their consents. To do this we provide the `LoadPrivacyManager` method. The following code snippet will show a GDPR privacy manager with default tab open.
191
+
Once a player has completed the consent flow, you might want to provide a way for them to resurface the privacy manager so they can see/manage their consents on an ongoing basis. To do this, we provide the `LoadPrivacyManager` method. The following code snippet will show a GDPR privacy manager with the default tab open.
192
+
175
193
```c#
176
194
publicvoidOnPrivacyManagerButtonClick()
177
195
{
@@ -180,7 +198,9 @@ Once a player has completed the consent flow, you may be interested to resurface
180
198
tab: PRIVACY_MANAGER_TAB.DEFAULT);
181
199
}
182
200
```
201
+
183
202
Below is a list of available tabs in a GDPR privacy manager:
203
+
184
204
```c#
185
205
publicenumPRIVACY_MANAGER_TAB
186
206
{
@@ -193,4 +213,4 @@ Below is a list of available tabs in a GDPR privacy manager:
193
213
194
214
# Build for iOS
195
215
196
-
Since Unity Editor exports the pre-built project to Xcode on iOS build, there are several necessary steps to perform so you can compile your solution. They are implemented inside the `CMPPostProcessBuild`[PostProcessBuild] script. Feel free supplement or modify it if needed.
216
+
Since Unity Editor exports the pre-built project to Xcode on iOS build, there are several necessary steps to perform so you can compile your solution. They are implemented inside the `CMPPostProcessBuild`[PostProcessBuild] script. Supplement or modify it if it is needed.
0 commit comments