@@ -59,81 +59,123 @@ A CMP compatible with TCF v2.2 collects DMA consent data and stores it in NSUser
5959 }
6060 },[])
6161```
62- ## Manually collect consent data
63- If your app does not use a CMP compatible with TCF v2.2, use the SDK API detailed below to provide the consent data directly to the SDK.
64-
65- ### When GDPR applies to the user
66- If GDPR applies to the user, perform the following:
67-
68- 1 . Given that GDPR is applicable to the user, determine whether the consent data is already stored for this session.
69- 1 . If there is no consent data stored, show the consent dialog to capture the user consent decision.
70- 2 . If there is consent data stored continue to the next step.
71- 2 . To transfer the consent data to the SDK create an AppsFlyerConsent object using ` forGDPRUser ` method that accepts the following parameters:<br >
72- ` hasConsentForDataUsage: boolean ` - Indicates whether the user has consented to use their data for advertising purposes.<br >
73- ` hasConsentForAdsPersonalization: boolean ` - Indicates whether the user has consented to use their data for personalized advertising.
74- 3 . Call ` appsFlyer.setConsentData(consentData) ` with the AppsFlyerConsent object.
75- 4 . Call ` appsFlyer.initSdk() ` .
62+
63+ ### Manually Collecting Consent Data
64+
65+ If your app does not use a TCF v2.2-compatible CMP, you must manually provide the consent data using the SDK API.
66+
67+ How to Set Consent Data: </br >
68+ 1. Determine GDPR Applicability:
69+ * If GDPR applies, check whether consent data is already stored.
70+ * If not stored, show a consent dialog to obtain user consent.
71+ 2. Create an AppsFlyerConsent object with the relevant parameters.
72+ 3. Pass the consent data to the SDK using appsFlyer.setConsentData(consentData).
73+ 4. Initialize the SDK with appsFlyer.initSdk().
74+
75+ #### Setting Consent Data for Users
76+
77+ <b >When GDPR Applies</b >
78+
79+ If GDPR applies to the user, create an AppsFlyerConsent object with the user’s preferences.
7680``` javascript
77- import appsFlyer , {AppsFlyerConsent } from ' react-native-appsflyer' ;
81+ import appsFlyer , { AppsFlyerConsent } from ' react-native-appsflyer' ;
7882
7983useEffect (() => {
8084 const option = {
81- isDebug: true ,
82- devKey: ' UxXxXxXxXd' ,
83- onInstallConversionDataListener: true ,
84- onDeepLinkListener: true ,
85- timeToWaitForATTUserAuthorization: 10 ,
85+ isDebug: true ,
86+ devKey: ' UxXxXxXxXd' ,
87+ onInstallConversionDataListener: true ,
88+ onDeepLinkListener: true ,
89+ timeToWaitForATTUserAuthorization: 10 ,
8690 };
8791
88- // user consent data
89- let consentData = AppsFlyerConsent . forGDPRUser (true , false );
92+ // User has given consent
93+ const consentData = new AppsFlyerConsent (true , true , true , true );
9094
95+ // Send consent data to the SDK
9196 appsFlyer .setConsentData (consentData);
9297
93- // start appsflyer
98+ // Start AppsFlyer SDK
9499 appsFlyer .initSdk (
95- option,
96- res => {
97- console .log (res);
98- },
99- err => {
100- console .log (err);
101- },
100+ option,
101+ res => console .log (res),
102+ err => console .log (err)
102103 );
103- }, [])
104+ }, []);
104105```
105- ### When GDPR does not apply to the user
106106
107- If GDPR doesn’t apply to the user perform the following:
108- 1 . Create an AppsFlyerConsent object using ` forNonGDPRUser ` method that doesn't accepts any parameters
109- 2 . Call ` appsFlyer.setConsentData(consentData) ` with the AppsFlyerConsent object.
110- 3 . Call ` appsFlyer.initSdk() ` .
107+ <b >When GDPR Does Not Apply</b >
108+
109+ If GDPR does not apply to the user, simply mark it as such in the AppsFlyerConsent object.
111110``` javascript
112- import appsFlyer , {AppsFlyerConsent } from ' react-native-appsflyer' ;
111+ import appsFlyer , { AppsFlyerConsent } from ' react-native-appsflyer' ;
113112
114113useEffect (() => {
115114 const option = {
116- isDebug: true ,
117- devKey: ' UxXxXxXxXd' ,
118- onInstallConversionDataListener: true ,
119- onDeepLinkListener: true ,
120- timeToWaitForATTUserAuthorization: 10 ,
115+ isDebug: true ,
116+ devKey: ' UxXxXxXxXd' ,
117+ onInstallConversionDataListener: true ,
118+ onDeepLinkListener: true ,
119+ timeToWaitForATTUserAuthorization: 10 ,
121120 };
122121
123122 // GDPR does not apply to the user
124- let consentData = AppsFlyerConsent . forNonGDPRUser ( );
123+ const consentData = new AppsFlyerConsent ( false );
125124
126- appsFlyer .setConsentData (consentData);
125+ // Send consent data to the SDK
126+ appsFlyer .setConsentData (consentData);
127127
128- // start appsflyer
128+ // Start AppsFlyer SDK
129129 appsFlyer .initSdk (
130- option,
131- res => {
132- console .log (res);
133- },
134- err => {
135- console .log (err);
136- },
130+ option,
131+ res => console .log (res),
132+ err => console .log (err)
137133 );
138- },[])
139- ```
134+ }, []);
135+ ```
136+
137+ ### Consent Object API
138+
139+ ``` javascript
140+ // AppsFlyerConsent Constructor:
141+
142+ new AppsFlyerConsent (
143+ isUserSubjectToGDPR, // Boolean (optional) - Whether GDPR applies to the user
144+ hasConsentForDataUsage, // Boolean (optional) - Consent for data usage
145+ hasConsentForAdsPersonalization, // Boolean (optional) - Consent for ads personalization
146+ hasConsentForAdStorage // Boolean (optional) - Consent for ad storage
147+ );
148+
149+ // Example Cases:
150+
151+ // Full consent for GDPR user
152+ const consent1 = new AppsFlyerConsent (true , true , true , true );
153+
154+ // No consent for GDPR user
155+ const consent2 = new AppsFlyerConsent (true , false , false , false );
156+
157+ // Non-GDPR user
158+ const consent3 = new AppsFlyerConsent (false );
159+
160+ // AppsFlyerConsent object support the following cases if they are needed.
161+ const consent4 = new AppsFlyerConsent (true );
162+ const consent5 = new AppsFlyerConsent (true , true );
163+ const consent6 = new AppsFlyerConsent (null , true , true , true );
164+ const consent7 = new AppsFlyerConsent (true , null , true , true );
165+ const consent8 = new AppsFlyerConsent (true , true , null , true );
166+ const consent9 = new AppsFlyerConsent (true , true , true , null );
167+ const consent10 = new AppsFlyerConsent (true , true , false , true );
168+ const consent11 = new AppsFlyerConsent (false , true , false , false );
169+ const consent12 = new AppsFlyerConsent (null , null , null , null );
170+ const consent13 = new AppsFlyerConsent ();
171+ ```
172+
173+ ### Deprecation Notice
174+
175+ The following methods have been deprecated since SDK version 6.16.2 and should no longer be used:
176+ ``` javascript
177+ // Deprecated since 6.16.2
178+ AppsFlyerConsent .forGDPRUser (true , false );
179+ AppsFlyerConsent .forNonGDPRUser ();
180+ ```
181+ Instead, use the new AppsFlyerConsent constructor.
0 commit comments