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
Use the node package manager install command to install the Sourcepoint React Native package:
6
13
7
14
```sh
8
15
npm install @sourcepoint/react-native-cmp
9
16
```
10
17
11
-
## Usage
18
+
## Configuration overview
19
+
20
+
In order to use the `SPConsentManager` you will need to perform the following:
12
21
13
-
### Overview
14
-
In a nutshell, in order to use the `SPConsentManager` you'll need:
15
-
1. Instantiate and call build with your configuration
16
-
2. Set up the callbacks in the instance of `SPConsentManager`
17
-
3. Call `loadMessages`. This will initiate the message, contact SP's servers, and it may or may not display a message, depending on your campaign scenario (configured in Sourcepoin't Dashboard).
18
-
4. Retrieve user data with `getUserData`.
22
+
1.[Instantiate and call build with your configuration](#instantiate-and-call-build-with-your-configuration)
23
+
2.[Set up callbacks in instance of `SPConsentManager`](#set-up-callbacks-in-instance-of-spconsentmanager)
24
+
3.[Call `loadMessages`](#call-loadmessages)
25
+
4.[Retrieve user data with `getUserData`](#retrieve-user-data-with-getuserdata)
19
26
20
-
Let's review each of the steps above in more detail.
27
+
In the sections below, we will review each of the steps in more detail:
21
28
22
29
### Instantiate and call build with your configuration
23
-
In your app, you can setup the SPConsent manager in a external file or on your App. In this example we use `useRef`
24
-
to keep a reference of the `SPConsentManager`. It's important to notice we wrap the initialisation of `SPConsentManager` in a `useEffect` and call `consentManager.current?.dispose()` to avoid memory leaks.
30
+
31
+
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`.
33
+
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.
| `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: {}` and/or `usnat: {}`. See table below for information on each campaign type. |
45
61
46
-
* `onSPUIReady(callback: () => {})`
47
-
This is called if the server determined a message should be displayed. The native SDKs will take care of the showing the message.
48
-
* `onAction(callback: (action:string) => {});`
49
-
Called when the user takes a action (e.g. accept all) within the consent message. `action: string` is going to be replaced with an enum.
50
-
* `onSPUIFinished(callback: () => {})`
51
-
Called when the native SDKs is done removing the consent UI from the foreground.
52
-
* `onFinished(callback: () => {})`
53
-
Called when all UI and network processes are finished. User consent is stored on the local storage of each platform (`UserDefaults` for iOS and `SharedPrefs` for Android). And it's safe to retrieve consent data with `getUserData`
54
-
* `onError(callback: (description:string) => {})`
55
-
Called if something go wrong.
62
+
Refer to the table below regarding the different campaigns that can be implemented:
63
+
64
+
>**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. |
78
+
| `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. |
79
+
| `onSPUIFinished(callback: () => {})` | Called when the native SDKs is done removing the consent UI from the foreground. |
80
+
| `onFinished(callback: () => {})` | Called when all UI and network processes are finished. User consent is stored on the local storage of each platform (`UserDefaults` for iOS and `SharedPrefs` for Android). And it is safe to retrieve consent data with `getUserData` |
81
+
| `onError(callback: (description:string) => {})` | Called if something goes wrong. |
56
82
57
83
### Call `loadMessages`
58
-
After instantiating and setting up `SPConsentManager`, configuring its callbacks, it's time to call `loadMessages`. 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.
84
+
85
+
After instantiating and setting up `SPConsentManager` and configuring its callbacks, it is time to call `loadMessages`.
86
+
87
+
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.
88
+
89
+
>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.
90
+
91
+
```ts
92
+
consentManager.current?.loadMessage();
93
+
```
59
94
60
95
### Retrieve user data with `getUserData`
61
96
`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`.
0 commit comments