@@ -181,9 +181,9 @@ public typealias TargetingParams = [String: String]
181
181
sourcePoint. getMessage ( consentUUID: consentUUID, authId: authId) { [ weak self] messageResponse, error in
182
182
self ? . loading = . Ready
183
183
if let message = messageResponse {
184
+ self ? . setLocalStorageData ( uuid: message. uuid, userConsent: message. userConsent, ccpaApplies: message. ccpaApplies)
184
185
self ? . consentUUID = message. uuid
185
- CCPAConsentViewController . setCCPAApplies ( message. ccpaApplies)
186
- CCPAConsentViewController . setUSPrivacyString ( message. userConsent. uspstring)
186
+ self ? . userConsent = message. userConsent
187
187
if let url = message. url {
188
188
self ? . loadMessage ( fromUrl: url)
189
189
} else {
@@ -196,6 +196,16 @@ public typealias TargetingParams = [String: String]
196
196
}
197
197
}
198
198
199
+ func setLocalStorageData( uuid: ConsentUUID , userConsent: UserConsent , ccpaApplies: Bool ) {
200
+ UserDefaults . standard. set ( uuid, forKey: CCPAConsentViewController . CONSENT_UUID_KEY)
201
+ CCPAConsentViewController . setUSPrivacyString ( userConsent. uspstring)
202
+ CCPAConsentViewController . setCCPAApplies ( ccpaApplies)
203
+ if let encodedConsents = try ? JSONEncoder ( ) . encode ( userConsent) {
204
+ UserDefaults . standard. set ( String ( data: encodedConsents, encoding: . utf8) , forKey: CCPAConsentViewController . CCPA_USER_CONSENTS)
205
+ }
206
+ UserDefaults . standard. synchronize ( )
207
+ }
208
+
199
209
func didAuthIdChange( newAuthId: String ? ) -> Bool {
200
210
let storedAuthId = UserDefaults . standard. string ( forKey: CCPAConsentViewController . CCPA_AUTH_ID_KEY)
201
211
return newAuthId != nil && storedAuthId != nil && storedAuthId != newAuthId
@@ -259,8 +269,9 @@ extension CCPAConsentViewController: ConsentDelegate {
259
269
if action == . AcceptAll || action == . RejectAll || action == . SaveAndExit {
260
270
sourcePoint. postAction ( action: action, consentUUID: consentUUID, consents: consents) { [ weak self] actionResponse, error in
261
271
if let response = actionResponse {
262
- CCPAConsentViewController . setUSPrivacyString ( response. userConsent. uspstring)
263
- CCPAConsentViewController . setCCPAApplies ( response. ccpaApplies)
272
+ self ? . consentUUID = response. uuid
273
+ self ? . userConsent = response. userConsent
274
+ self ? . setLocalStorageData ( uuid: response. uuid, userConsent: response. userConsent, ccpaApplies: response. ccpaApplies)
264
275
self ? . onConsentReady ( consentUUID: response. uuid, userConsent: response. userConsent)
265
276
} else {
266
277
self ? . onError ( error: error)
@@ -270,13 +281,6 @@ extension CCPAConsentViewController: ConsentDelegate {
270
281
}
271
282
272
283
public func onConsentReady( consentUUID: ConsentUUID , userConsent: UserConsent ) {
273
- self . consentUUID = consentUUID
274
- self . userConsent = userConsent
275
- if let encodedConsents = try ? JSONEncoder ( ) . encode ( userConsent) {
276
- UserDefaults . standard. set ( String ( data: encodedConsents, encoding: . utf8) , forKey: CCPAConsentViewController . CCPA_USER_CONSENTS)
277
- }
278
- UserDefaults . standard. set ( consentUUID, forKey: CCPAConsentViewController . CONSENT_UUID_KEY)
279
- UserDefaults . standard. synchronize ( )
280
284
consentDelegate? . onConsentReady ? ( consentUUID: consentUUID, userConsent: userConsent)
281
285
}
282
286
0 commit comments