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 @@ -6,6 +6,8 @@ import com.sourcepoint.cmplibrary.model.CampaignsEnv.*
import com.sourcepoint.cmplibrary.model.exposed.ActionType
import com.sourcepoint.cmplibrary.model.exposed.ActionType.*
import com.sourcepoint.cmplibrary.model.exposed.TargetingParam
import com.sourcepoint.cmplibrary.data.network.util.CampaignType
import com.sourcepoint.cmplibrary.data.network.util.CampaignType.*

fun campaignsEnvFrom(rawValue: String?): CampaignsEnv? =
when (rawValue) {
Expand All @@ -14,6 +16,15 @@ fun campaignsEnvFrom(rawValue: String?): CampaignsEnv? =
else -> { null }
}

fun campaignTypeFrom(rawValue: String?): CampaignType =
when (rawValue) {
"gdpr" -> GDPR
"usnat" -> USNAT
"globalcmp" -> GLOBALCMP
"preferences" -> PREFERENCES
else -> { CampaignType.UNKNOWN }
}

data class SPCampaign(
val rawTargetingParam: ReadableMap?,
val supportLegacyUSPString: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ class ReactNativeCmpModule(reactContext: ReactApplicationContext) : NativeReactN
}
}

override fun rejectAll(campaignType: String) {
runOnMainThread {
spConsentLib?.rejectAll(campaignTypeFrom(campaignType))
}
}

companion object {
const val NAME = "ReactNativeCmp"
}
Expand Down
11 changes: 11 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { LaunchArguments } from 'react-native-launch-arguments';

import SPConsentManager, {
SPCampaignEnvironment,
SPCampaignType,
SPMessageLanguage,
} from '@sourcepoint/react-native-cmp';
import type { GDPRConsent, SPCampaigns, SPUserData } from '@sourcepoint/react-native-cmp';
Expand Down Expand Up @@ -122,6 +123,11 @@ export default function App() {
consentManager.current?.loadGDPRPrivacyManager(config.gdprPMId);
}, []);

const onRejectAllGDPRPMPress = useCallback(() => {
setSDKStatus(SDKStatus.Networking);
consentManager.current?.rejectAll(SPCampaignType.Gdpr);
}, []);

const onUSNATPMPress = useCallback(() => {
setSDKStatus(SDKStatus.Networking);
consentManager.current?.loadUSNatPrivacyManager(config.usnatPMId);
Expand Down Expand Up @@ -202,6 +208,11 @@ export default function App() {
onPress={onGDPRPMPress}
disabled={disable || config.campaigns.gdpr === undefined}
/>
<Button
title="Reject All GDPR"
onPress={onRejectAllGDPRPMPress}
disabled={disable || config.campaigns.gdpr === undefined}
/>
<Button
title="Load USNAT PM"
onPress={onUSNATPMPress}
Expand Down
4 changes: 4 additions & 0 deletions ios/RNSourcepointCmp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ import React
}
}

public func rejectAll(_ campaignType: String) {
consentManager?.rejectAll(campaignType: SPCampaignType(rawValue: campaignType == "gdpr" ? "GDPR" : campaignType ))
}

weak var rootViewController: UIViewController? {
UIApplication.shared.delegate?.window??.rootViewController
}
Expand Down
4 changes: 4 additions & 0 deletions ios/ReactNativeCmp.mm
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ - (void)postDeleteCustomConsentGDPR:(NSArray *)vendors
[sdk postDeleteCustomConsentGDPR:vendors :categories :legIntCategories :callback];
}

- (void)rejectAll:(nonnull NSString *)campaignType {
[sdk rejectAll:campaignType];
}

// MARK: SPDelegate
- (void)onAction:(RNAction*)action {
[self emitInternalOnAction: [action stringifiedJson]];
Expand Down
9 changes: 9 additions & 0 deletions src/NativeReactNativeCmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ export const enum SPCampaignEnvironment {
Stage = 'Stage',
}

export const enum SPCampaignType {
Gdpr = "gdpr",
UsNat = "usnat",
IOS14 = "ios14",
Preferences = "preferences",
GlobalCmp = "globalcmp",
}

export const enum SPMessageLanguage {
ALBANIAN = 'sq',
ARABIC = 'ar',
Expand Down Expand Up @@ -233,6 +241,7 @@ export interface Spec extends TurboModule {
legIntCategories: string[],
callback: (consent: GDPRConsent) => void
): void;
rejectAll(campaignType: SPCampaignType): void;

readonly internalOnAction: EventEmitter<string>;
readonly onSPUIReady: EventEmitter<void>;
Expand Down
5 changes: 5 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
SPAction,
SPBuildOptions,
GDPRConsent,
SPCampaignType,
SPError
} from './NativeReactNativeCmp';
import ReactNativeCmp, { SPMessageLanguage } from './NativeReactNativeCmp';
Expand Down Expand Up @@ -104,4 +105,8 @@ export default class SPConsentManager implements Spec {
) {
ReactNativeCmp.postDeleteCustomConsentGDPR(vendors, categories, legIntCategories, callback);
}

rejectAll(campaignType: SPCampaignType) {
ReactNativeCmp.rejectAll(campaignType)
}
}
Loading