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
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`.
15
19
16
-
// ...
20
+
Let's review each of the steps above in more detail.
17
21
18
-
constresult=awaitmultiply(3, 7);
22
+
### 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.
### Set up the callbacks in the instance of `SPConsentManager`
44
+
`SPConsentManager` communicates with your app through a series of callbacks.
45
+
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.
56
+
57
+
### 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.
59
+
60
+
### Retrieve user data with `getUserData`
61
+
`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