Skip to content

Commit 4ba033b

Browse files
authored
Merge pull request #6 from SourcePointUSA/tom-win87-patch-1
Update README.md
2 parents 4a3eb45 + 4c6bd71 commit 4ba033b

File tree

1 file changed

+45
-25
lines changed

1 file changed

+45
-25
lines changed

README.md

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
# Unity-SDK
2-
Your plug & play CMP for Unity.
32

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

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+
---
79

810
# Instantiate consent UI
911

1012
To start, include the following library namepsace in your script:
13+
1114
```c#
1215
using ConsentManagementProviderLib;
1316
```
1417

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.
19+
1620
```c#
1721
List<SpCampaign> spCampaigns = new List<SpCampaign>();
1822

@@ -29,7 +33,8 @@ using ConsentManagementProviderLib;
2933
spCampaigns.Add(ios14);
3034
```
3135

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+
3338
```c#
3439
CMP.Initialize(spCampaigns: spCampaigns,
3540
accountId: 22,
@@ -39,16 +44,19 @@ using ConsentManagementProviderLib;
3944
messageTimeoutInSeconds: 3);
4045
```
4146

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

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.
4551
```c#
4652
private void Start()
4753
{
4854
CMP.LoadMessage(authId: null); // or pass it a String if you wish to use authenticated consent
4955
}
5056
```
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+
5260
```c#
5361
private void OnDestroy()
5462
{
@@ -60,15 +68,16 @@ private void OnDestroy()
6068

6169
Consent callbacks allow you to track progress and receive updates of user interaction. We provide the following interfaces:
6270

63-
| Callback | Description |
64-
|------------------------|-------------------------------------------------------------------------------------------------------------------------|
65-
| `IOnConsentUIReady` | Triggered when web view UI is ready and about to show |
66-
| `IOnConsentAction` | Triggered when user made an action, provides you instance of enum `CONSENT_ACTION_TYPE`. See below for more information.|
67-
| `IOnConsentError` | Triggered when something went wrong, provides you instance of Exception |
68-
| `IOnConsentUIFinished` | Triggered when user interaction with web view UI is done and view is about to disappear |
69-
| `IOnConsentReady` | Triggered when server successfully reacted to user's consent, provides you `SpConsent` object with consent info |
71+
| Callback | Description |
72+
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------ |
73+
| `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 |
7078

7179
`CONSENT_ACTION_TYPE` can return the following:
80+
7281
```c#
7382
public enum CONSENT_ACTION_TYPE
7483
{
@@ -82,9 +91,13 @@ public enum CONSENT_ACTION_TYPE
8291
```
8392

8493
# 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?
100+
88101
```c#
89102
public class ConsentEventHandler : MonoBehaviour, IOnConsentError
90103
{
@@ -94,24 +107,28 @@ public class ConsentEventHandler : MonoBehaviour, IOnConsentError
94107
}
95108
}
96109
```
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.
114+
98115
```c#
99116
void Awake()
100117
{
101118
ConsentMessenger.AddListener<IOnConsentError>(this.gameObject);
102119
}
103120
```
104-
⤤ 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>
106121

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:
123+
108124
```c#
109125
private void OnDestroy()
110126
{
111127
ConsentMessenger.RemoveListener<IOnConsentError>(this.gameObject);
112128
}
113129
```
114-
4. The solution is ready. Configure it and deploy!
130+
131+
The solution is ready. Configure it and deploy!
115132

116133
Both calling & handling workflows are implemented in the `ConsentMessageProvider` and `ConsentEventHandler` scripts of our example app accordingly. Feel free to use these components.
117134

@@ -171,7 +188,8 @@ public class ConsentEventHandler : MonoBehaviour, IOnConsentUIReady, IOnConsentA
171188

172189
# Resurface Privacy Manager
173190

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+
175193
```c#
176194
public void OnPrivacyManagerButtonClick()
177195
{
@@ -180,7 +198,9 @@ Once a player has completed the consent flow, you may be interested to resurface
180198
tab: PRIVACY_MANAGER_TAB.DEFAULT);
181199
}
182200
```
201+
183202
Below is a list of available tabs in a GDPR privacy manager:
203+
184204
```c#
185205
public enum PRIVACY_MANAGER_TAB
186206
{
@@ -193,4 +213,4 @@ Below is a list of available tabs in a GDPR privacy manager:
193213

194214
# Build for iOS
195215

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

Comments
 (0)