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
Sourcepoint's React Native SDK v1.0.0+ utilizes and is only compatible with [React Native's new architecture](#https://reactnative.dev/architecture/landing-page). Any projects implementing the latest version of the SDK will need to ensure their project uses the new architecture.
14
+
10
15
## Install Sourcepoint package
11
16
12
17
Use the node package manager install command to install the Sourcepoint React Native package:
In order to use the `SPConsentManager`you will need to perform the following:
25
+
In order to use the `SPConsentManager` you will need to perform the following:
21
26
22
27
1.[Instantiate and call build with your configuration](#instantiate-and-call-build-with-your-configuration)
23
28
2.[Set up callbacks in instance of `SPConsentManager`](#set-up-callbacks-in-instance-of-spconsentmanager)
24
-
3.[Call `loadMessages`](#call-loadmessages)
29
+
3.[Call `loadMessages`](#call-loadmessages)
25
30
4.[Retrieve user data with `getUserData`](#retrieve-user-data-with-getuserdata)
26
31
27
32
In the sections below, we will review each of the steps in more detail:
28
33
29
34
### Instantiate and call build with your configuration
30
35
31
36
In your app, you can setup the SPConsent manager in a external file or on your app. In the example below we use `useRef`
32
-
to keep a reference of the `SPConsentManager`.
37
+
to keep a reference of the `SPConsentManager`.
33
38
34
-
>It is important to notice that we wrap the initialisation of `SPConsentManager` in a `useEffect` and call `consentManager.current?.dispose()` to avoid memory leaks.
39
+
>It is important to notice that we wrap the initialisation of `SPConsentManager` in a `useEffect` and call `consentManager.current?.dispose()` to avoid memory leaks.
| `config.accountId` | Number | Value associates the property with your organization's Sourcepoint account. Retrieved by contacting your Sourcepoint Account Manager or via the **My Account** page in the Sourcepoint portal. |
58
-
| `config.propertyId` | Number | ID for property found in the Sourcepoint portal |
59
-
| `config.propertyName` | String | Name of property found in the Sourcepoint portal |
60
-
| `config.campaigns` | Object | Campaigns launched on the property through the Sourcepoint portal. Accepts `gdpr: {}`, `usnat: {}`, `preferences: {}` and `globalcmp: {}`. See table below for information on each campaign type. |
| `config.accountId` | Number | Value associates the property with your organization's Sourcepoint account. Retrieved by contacting your Sourcepoint Account Manager or via the **My Account** page in the Sourcepoint portal. |
64
+
| `config.propertyId` | Number | ID for property found in the Sourcepoint portal |
65
+
| `config.propertyName` | String | Name of property found in the Sourcepoint portal |
66
+
| `config.campaigns` | Object | Campaigns launched on the property through the Sourcepoint portal. Accepts `gdpr: {}`, `usnat: {}`, `preferences: {}` and `globalcmp: {}`. See table below for information on each campaign type. |
61
67
62
68
Refer to the table below regarding the different campaigns that can be implemented:
63
69
64
-
>**NOTE**: Only include the campaign objects for which there is a campaign enabled on the property within the Sourcepoint portal.
70
+
>**NOTE**: Only include the campaign objects for which there is a campaign enabled on the property within the Sourcepoint portal.
| `onSPUIReady(callback: () => {})` | Called if the server determines a message should be displayed. The native SDKs will take care of showing the message. |
80
86
| `onAction(callback: (action:string) => {})` | Called when the user takes an action (e.g. Accept All) within the consent message. `action: string` is going to be replaced with an enum. |
81
87
| `onSPUIFinished(callback: () => {})` | Called when the native SDKs is done removing the consent UI from the foreground. |
@@ -84,17 +90,18 @@ Refer to the table below regarding the different campaigns that can be implement
84
90
85
91
### Call `loadMessages`
86
92
87
-
After instantiating and setting up `SPConsentManager` and configuring its callbacks, it is time to call `loadMessages`.
93
+
After instantiating and setting up `SPConsentManager` and configuring its callbacks, it is time to call `loadMessages`.
88
94
89
95
Calling `loadMessages` will initiate the message, contact Sourcepoint's servers, and it may or may not display a message, depending on the scenario configured in the Sourcepoint portal for the property's message campaign.
90
96
91
-
>This can be done at any stage of your app's lifecycle. Ideally you will want to call it as early as possible, in order to have consent for your vendors.
97
+
>This can be done at any stage of your app's lifecycle. Ideally you will want to call it as early as possible, in order to have consent for your vendors.
92
98
93
99
```ts
94
100
consentManager.current?.loadMessage();
95
101
```
96
102
97
103
### Retrieve user data with `getUserData`
104
+
98
105
`getUserData` returns a `Promise<SPUserData>`. You can call this function at any point in your app's lifecycle, but consent may or may not yet be ready. The safest place to call it is inside the callback `onSPFinished`.
| `dateCreated` | String | Date the end-user preferences record was created. |
171
+
| `uuid` | String | Unique user ID generated for end-user for which preferences record is stored against. |
172
+
| `status` | Array | An array of objects for each category that has been accepted by the end user. Please review the structure of this object in the table below. |
173
+
| `rejectedStatus` | Array | An array of objects for each category that has been rejected by the end user. Please review the structure of this object in the table below. |
174
+
175
+
The following table details the structure of category objects that can be returned in the `status` or `rejectedStatus` array.
| `categoryId` | Number | ID of category as found in the Preferences configuration |
180
+
| `channels` | Array | Returned when the category is a Marketing Preference category. Object `{id: number, status: boolean}` represents the channel accepted/rejected by the end-user. Available responses for `id` are: 0 = Email, 1 = SMS, 2 = Whatsapp, 3 = Phone, 4 = Mail, 5 = Test.<br><br> `status` reflects whether the end-user has accepted the channel |
181
+
| `changed` | Boolean | For internal purposes only. |
182
+
| `dateConsented` | String | Date end-user made their decision on the Marketing Preference or Legal Preference category |
183
+
| `subType` | String | Returned when the category is a Legal Preference category and reflects the **Document Type** selected for the Legal Preference category. |
| `applies` | Boolean | `true`: end-user's region is in the framework territories \|`false`: end-user's region is not in the framework territories |
201
+
| `uuid` | String | Unique user ID generated for end-user for which Global Enterprise consent record is stored against. |
202
+
| `expirationDate` | String | Date the end-user's consent record expires. |
203
+
| `createdDate` | String | Date the end-user's consent record was created. |
204
+
| `vendors` | Array | Vendors configured in your Global Enterprise vendor list and their consent status. `{id: string, consented: boolean}` <br><br> `id` is the ID of the privacy choice. <br><br> `consented` refers to whetherthe privacy choice was opted into by the end-user |
205
+
| `categories` | Array | Privacy choices that are applicable to the end-users region and opt-in status for each. `{id: string, consented: boolean}`.<br><br> `id` is the ID of the privacy choice.<br><br> `consented` refers to whetherthe privacy choice was opted into by the end-user |
206
+
169
207
## React example
170
208
171
209
In the example below, you can find a fully configured example in React:
@@ -227,6 +265,7 @@ export default function App() {
227
265
```
228
266
229
267
## Implementing authenticated consent
268
+
230
269
In a nutshell, you provide an identifier for the current user (username, user id, uuid or any unique string) and we'll take care of associating the consent profile to that identifier.
231
270
232
271
In order to use the authenticated consent all you need to do is replace `.loadMessage()` with `.loadMessage({ authId: "JohnDoe"}))`.
@@ -235,12 +274,12 @@ If our APIs have a consent profile associated with that token `"JohnDoe"` the SD
235
274
236
275
## Complete App example
237
276
238
-
Complete app example for iOS and Android can be found in the [`/example`](/example/) folder of the SDK.
277
+
Complete app example for iOS and Android can be found in the [`/example`](/example/) folder of the SDK.
239
278
240
279
## Known issues
280
+
241
281
On iOS, reloading the app's bundle (ie. pressing r while the emulator is open or on Webpack's console) causes React Native to stop emitting events. This issue is being investigated and it's pottentially within React Native itself.
0 commit comments