Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ internal class RNUsercentricsModule(
}

@ReactMethod
override fun denyAllForTCF(fromLayer: Double, consentType: Double, unsavedPurposeLIDecisions: ReadableArray, promise: Promise) {
override fun denyAllForTCF(fromLayer: Double, consentType: Double, unsavedPurposeLIDecisions: ReadableArray, unsavedVendorLIDecisions: ReadableArray, promise: Promise) {
promise.resolve(
usercentricsProxy.instance.denyAllForTCF(
TCFDecisionUILayer.values()[fromLayer.toInt()], UsercentricsConsentType.values()[consentType.toInt()], unsavedPurposeLIDecisions.deserializePurposeLIDecisionsMap()
TCFDecisionUILayer.values()[fromLayer.toInt()], UsercentricsConsentType.values()[consentType.toInt()], unsavedPurposeLIDecisions.deserializePurposeLIDecisionsMap(), unsavedVendorLIDecisions.deserializePurposeLIDecisionsMap()
).toWritableArray()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ abstract class RNUsercentricsModuleSpec internal constructor(context: ReactAppli
abstract fun denyAll(consentType: Double, promise: Promise)

@ReactMethod
abstract fun denyAllForTCF(fromLayer: Double, consentType: Double, unsavedPurposeLIDecisions: ReadableArray, promise: Promise)
abstract fun denyAllForTCF(fromLayer: Double, consentType: Double, unsavedPurposeLIDecisions: ReadableArray, unsavedVendorLIDecisions: ReadableArray, promise: Promise)

@ReactMethod
abstract fun saveDecisions(decisions: ReadableArray, consentType: Double, promise: Promise)
Expand Down
6 changes: 3 additions & 3 deletions ios/Manager/UsercentricsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public protocol UsercentricsManager {
func acceptAllForTCF(fromLayer: TCFDecisionUILayer, consentType: UsercentricsConsentType) -> [UsercentricsServiceConsent]
func acceptAll(consentType: UsercentricsConsentType) -> [UsercentricsServiceConsent]

func denyAllForTCF(fromLayer: TCFDecisionUILayer, consentType: UsercentricsConsentType, unsavedPurposeLIDecisions: [KotlinInt: KotlinBoolean]?) -> [UsercentricsServiceConsent]
func denyAllForTCF(fromLayer: TCFDecisionUILayer, consentType: UsercentricsConsentType, unsavedPurposeLIDecisions: [KotlinInt: KotlinBoolean]?, unsavedVendorLIDecisions: [KotlinInt: KotlinBoolean]?) -> [UsercentricsServiceConsent]
func denyAll(consentType: UsercentricsConsentType) -> [UsercentricsServiceConsent]

func saveDecisionsForTCF(tcfDecisions: TCFUserDecisions,
Expand Down Expand Up @@ -132,8 +132,8 @@ final class UsercentricsManagerImplementation: UsercentricsManager {
return UsercentricsCore.shared.acceptAll(consentType: consentType)
}

func denyAllForTCF(fromLayer: TCFDecisionUILayer, consentType: UsercentricsConsentType, unsavedPurposeLIDecisions: [KotlinInt: KotlinBoolean]?) -> [UsercentricsServiceConsent] {
return UsercentricsCore.shared.denyAllForTCF(fromLayer: fromLayer, consentType: consentType, unsavedPurposeLIDecisions: unsavedPurposeLIDecisions)
func denyAllForTCF(fromLayer: TCFDecisionUILayer, consentType: UsercentricsConsentType, unsavedPurposeLIDecisions: [KotlinInt: KotlinBoolean]?, unsavedVendorLIDecisions: [KotlinInt: KotlinBoolean]?) -> [UsercentricsServiceConsent] {
return UsercentricsCore.shared.denyAllForTCF(fromLayer: fromLayer, consentType: consentType, unsavedPurposeLIDecisions: unsavedPurposeLIDecisions, unsavedVendorLIDecisions: unsavedVendorLIDecisions)
}

func denyAll(consentType: UsercentricsConsentType) -> [UsercentricsServiceConsent] {
Expand Down
1 change: 1 addition & 0 deletions ios/RNUsercentricsModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ @interface RCT_EXTERN_MODULE(RNUsercentricsModule, NSObject)
RCT_EXTERN_METHOD(denyAllForTCF:(double)fromLayer
consentType:(double)consentType
unsavedPurposeLIDecisions:(NSArray)unsavedPurposeLIDecisions
unsavedVendorLIDecisions:(NSArray)unsavedVendorLIDecisions
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)

Expand Down
26 changes: 16 additions & 10 deletions ios/RNUsercentricsModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,26 @@ class RNUsercentricsModule: RCTEventEmitter {
@objc func denyAllForTCF(_ fromLayer: Double,
consentType: Double,
unsavedPurposeLIDecisions: [NSDictionary],
unsavedVendorLIDecisions: [NSDictionary],
resolve: @escaping RCTPromiseResolveBlock,
reject: @escaping RCTPromiseRejectBlock) -> Void {
var decisions: [KotlinInt: KotlinBoolean]? = nil
if !unsavedPurposeLIDecisions.isEmpty {
decisions = [:]
for dict in unsavedPurposeLIDecisions {
if let id = dict["id"] as? Int,
let consent = dict["legitimateInterestConsent"] as? Bool {
decisions?[KotlinInt(int: Int32(id))] = KotlinBoolean(bool: consent)
}
let services = usercentricsManager.denyAllForTCF(
fromLayer: .initialize(from: Int(fromLayer)),
consentType: .initialize(from: Int(consentType)),
unsavedPurposeLIDecisions: extractLIDecisionsMap(unsavedPurposeLIDecisions),
unsavedVendorLIDecisions: extractLIDecisionsMap(unsavedVendorLIDecisions)
)
resolve(services.toListOfDictionary())
}

private func extractLIDecisionsMap(_ decisions: [NSDictionary]) -> [KotlinInt: KotlinBoolean]? {
guard !decisions.isEmpty else { return nil }
return decisions.reduce(into: [:]) { result, dict in
if let id = dict["id"] as? Int,
let consent = dict["legitimateInterestConsent"] as? Bool {
result[KotlinInt(int: Int32(id))] = KotlinBoolean(bool: consent)
}
}
let services = usercentricsManager.denyAllForTCF(fromLayer: .initialize(from: Int(fromLayer)), consentType: .initialize(from: Int(consentType)), unsavedPurposeLIDecisions: decisions)
resolve(services.toListOfDictionary())
}

@objc func denyAll(_ consentType: Double,
Expand Down
3 changes: 2 additions & 1 deletion src/NativeUsercentrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
UserDecision,
TCFUserDecisions,
TCFUserDecisionOnPurpose,
TCFUserDecisionOnVendor,
} from './models';

export interface Spec extends TurboModule {
Expand Down Expand Up @@ -50,7 +51,7 @@ export interface Spec extends TurboModule {
acceptAll(consentType: number): Promise<Array<UsercentricsServiceConsent>>;
acceptAllForTCF(fromLayer: number, consentType: number): Promise<Array<UsercentricsServiceConsent>>;
denyAll(consentType: number): Promise<Array<UsercentricsServiceConsent>>;
denyAllForTCF(fromLayer: number, consentType: number, unsavedPurposeLIDecisions: Array<TCFUserDecisionOnPurpose>): Promise<Array<UsercentricsServiceConsent>>;
denyAllForTCF(fromLayer: number, consentType: number, unsavedPurposeLIDecisions: Array<TCFUserDecisionOnPurpose>, unsavedVendorLIDecisions: Array<TCFUserDecisionOnVendor>): Promise<Array<UsercentricsServiceConsent>>;

saveDecisions(decisions: Array<UserDecision>, consentType: number): Promise<Array<UsercentricsServiceConsent>>;
saveDecisionsForTCF(
Expand Down
5 changes: 3 additions & 2 deletions src/Usercentrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
TCFData,
TCFDecisionUILayer,
TCFUserDecisionOnPurpose,
TCFUserDecisionOnVendor,
TCFUserDecisions,
UsercentricsAnalyticsEventType,
UsercentricsCMPData,
Expand Down Expand Up @@ -119,9 +120,9 @@ export const Usercentrics = {
return RNUsercentricsModule.denyAll(consentType);
},

denyAllForTCF: async (fromLayer: TCFDecisionUILayer, consentType: UsercentricsConsentType, unsavedPurposeLIDecisions: TCFUserDecisionOnPurpose[] = []): Promise<Array<UsercentricsServiceConsent>> => {
denyAllForTCF: async (fromLayer: TCFDecisionUILayer, consentType: UsercentricsConsentType, unsavedPurposeLIDecisions: TCFUserDecisionOnPurpose[] = [], unsavedVendorLIDecisions: TCFUserDecisionOnVendor[] = []): Promise<Array<UsercentricsServiceConsent>> => {
await RNUsercentricsModule.isReady();
return RNUsercentricsModule.denyAllForTCF(fromLayer, consentType, unsavedPurposeLIDecisions);
return RNUsercentricsModule.denyAllForTCF(fromLayer, consentType, unsavedPurposeLIDecisions, unsavedVendorLIDecisions);
},

saveDecisions: async (decisions: UserDecision[], consentType: UsercentricsConsentType): Promise<Array<UsercentricsServiceConsent>> => {
Expand Down
2 changes: 1 addition & 1 deletion src/fabric/NativeUsercentricsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface Spec extends TurboModule {
acceptAll(consentType: number): Promise<Array<Object>>;
acceptAllForTCF(fromLayer: number, consentType: number): Promise<Array<Object>>;
denyAll(consentType: number): Promise<Array<Object>>;
denyAllForTCF(fromLayer: number, consentType: number, unsavedPurposeLIDecisions: Array<Object>): Promise<Array<Object>>;
denyAllForTCF(fromLayer: number, consentType: number, unsavedPurposeLIDecisions: Array<Object>, unsavedVendorLIDecisions: Array<Object>): Promise<Array<Object>>;

saveDecisions(decisions: Array<Object>, consentType: number): Promise<Array<Object>>;
saveDecisionsForTCF(
Expand Down
Loading