cm-sdk-react-native-v3 3.5.3 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/android/build.gradle +5 -5
- package/android/gradle.properties +3 -3
- package/android/src/main/java/com/cmsdkreactnativev3/CmSdkReactNativeV3Module.kt +43 -139
- package/android/src/main/java/com/cmsdkreactnativev3/CmSdkReactNativeV3Package.kt +24 -4
- package/ios/CmSdkReactNativeV3-Bridging-Header.h +4 -0
- package/ios/CmSdkReactNativeV3.mm +42 -76
- package/ios/CmSdkReactNativeV3.swift +37 -120
- package/lib/commonjs/NativeCmSdkReactNativeV3.js +11 -0
- package/lib/commonjs/NativeCmSdkReactNativeV3.js.map +1 -0
- package/lib/commonjs/index.js +108 -36
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeCmSdkReactNativeV3.js +10 -0
- package/lib/module/NativeCmSdkReactNativeV3.js.map +1 -0
- package/lib/module/index.js +86 -34
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/NativeCmSdkReactNativeV3.d.ts +68 -0
- package/lib/typescript/commonjs/src/NativeCmSdkReactNativeV3.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +25 -32
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeCmSdkReactNativeV3.d.ts +68 -0
- package/lib/typescript/module/src/NativeCmSdkReactNativeV3.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +25 -32
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +8 -2
- package/react-native-cm-sdk-react-native-v3.podspec +1 -1
- package/src/NativeCmSdkReactNativeV3.ts +92 -0
- package/src/index.tsx +125 -39
package/src/index.tsx
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { NativeModules, Platform, NativeEventEmitter } from 'react-native';
|
|
2
|
+
import NativeCmSdkReactNativeV3, {
|
|
3
|
+
type ConsentReceivedEvent,
|
|
4
|
+
type ErrorEvent,
|
|
5
|
+
type LinkClickEvent,
|
|
6
|
+
type ATTStatusChangeEvent,
|
|
7
|
+
type UrlConfig,
|
|
8
|
+
type WebViewConfig,
|
|
9
|
+
type UserStatus,
|
|
10
|
+
type GoogleConsentModeStatus,
|
|
11
|
+
} from './NativeCmSdkReactNativeV3';
|
|
2
12
|
|
|
3
13
|
const LINKING_ERROR =
|
|
4
14
|
`The package 'react-native-cm-sdk-react-native-v3' doesn't seem to be linked. Make sure: \n\n` +
|
|
@@ -6,7 +16,8 @@ const LINKING_ERROR =
|
|
|
6
16
|
'- You rebuilt the app after installing the package\n' +
|
|
7
17
|
'- You are not using Expo Go\n';
|
|
8
18
|
|
|
9
|
-
|
|
19
|
+
// Use TurboModule if available (New Architecture), fallback to legacy NativeModules
|
|
20
|
+
const CmSdkReactNativeV3 = NativeCmSdkReactNativeV3 ?? (NativeModules.CmSdkReactNativeV3
|
|
10
21
|
? NativeModules.CmSdkReactNativeV3
|
|
11
22
|
: new Proxy(
|
|
12
23
|
{},
|
|
@@ -15,14 +26,16 @@ const CmSdkReactNativeV3 = NativeModules.CmSdkReactNativeV3
|
|
|
15
26
|
throw new Error(LINKING_ERROR);
|
|
16
27
|
},
|
|
17
28
|
}
|
|
18
|
-
);
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
export const isTurboModuleEnabled = NativeCmSdkReactNativeV3 != null;
|
|
19
32
|
|
|
20
33
|
const eventEmitter = new NativeEventEmitter(CmSdkReactNativeV3);
|
|
21
34
|
|
|
22
35
|
export const addConsentListener = (
|
|
23
|
-
callback: (consent: string, jsonObject:
|
|
36
|
+
callback: (consent: string, jsonObject: Object) => void
|
|
24
37
|
) => {
|
|
25
|
-
return eventEmitter.addListener('didReceiveConsent', (event) => {
|
|
38
|
+
return eventEmitter.addListener('didReceiveConsent', (event: ConsentReceivedEvent) => {
|
|
26
39
|
callback(event.consent, event.jsonObject);
|
|
27
40
|
});
|
|
28
41
|
};
|
|
@@ -36,55 +49,128 @@ export const addCloseConsentLayerListener = (callback: () => void) => {
|
|
|
36
49
|
};
|
|
37
50
|
|
|
38
51
|
export const addErrorListener = (callback: (error: string) => void) => {
|
|
39
|
-
return eventEmitter.addListener('didReceiveError', (event) => {
|
|
52
|
+
return eventEmitter.addListener('didReceiveError', (event: ErrorEvent) => {
|
|
40
53
|
callback(event.error);
|
|
41
54
|
});
|
|
42
55
|
};
|
|
43
56
|
|
|
44
57
|
export const addClickLinkListener = (callback: (url: string) => void) => {
|
|
45
|
-
return eventEmitter.addListener('onClickLink', (event) => {
|
|
58
|
+
return eventEmitter.addListener('onClickLink', (event: LinkClickEvent) => {
|
|
46
59
|
callback(event.url);
|
|
47
60
|
});
|
|
48
61
|
};
|
|
49
62
|
|
|
63
|
+
export const addATTStatusChangeListener = (callback: (event: ATTStatusChangeEvent) => void) => {
|
|
64
|
+
return eventEmitter.addListener('didChangeATTStatus', callback);
|
|
65
|
+
};
|
|
66
|
+
|
|
50
67
|
// Core configuration methods
|
|
51
|
-
export const setUrlConfig =
|
|
52
|
-
|
|
68
|
+
export const setUrlConfig = (config: UrlConfig): Promise<void> => {
|
|
69
|
+
return CmSdkReactNativeV3.setUrlConfig(config);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const setWebViewConfig = (config: WebViewConfig): Promise<void> => {
|
|
73
|
+
return CmSdkReactNativeV3.setWebViewConfig(config);
|
|
74
|
+
};
|
|
53
75
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
76
|
+
export const setATTStatus = (status: number): Promise<void> => {
|
|
77
|
+
return CmSdkReactNativeV3.setATTStatus(status);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Main interaction methods
|
|
81
|
+
export const checkAndOpen = (jumpToSettings: boolean): Promise<boolean> => {
|
|
82
|
+
return CmSdkReactNativeV3.checkAndOpen(jumpToSettings);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const forceOpen = (jumpToSettings: boolean): Promise<boolean> => {
|
|
86
|
+
return CmSdkReactNativeV3.forceOpen(jumpToSettings);
|
|
87
|
+
};
|
|
58
88
|
|
|
59
89
|
// Consent status methods
|
|
60
|
-
export const getUserStatus =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
export const
|
|
65
|
-
|
|
66
|
-
|
|
90
|
+
export const getUserStatus = (): Promise<UserStatus> => {
|
|
91
|
+
return CmSdkReactNativeV3.getUserStatus();
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const getStatusForPurpose = (purposeId: string): Promise<string> => {
|
|
95
|
+
return CmSdkReactNativeV3.getStatusForPurpose(purposeId);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const getStatusForVendor = (vendorId: string): Promise<string> => {
|
|
99
|
+
return CmSdkReactNativeV3.getStatusForVendor(vendorId);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const getGoogleConsentModeStatus = (): Promise<GoogleConsentModeStatus> => {
|
|
103
|
+
return CmSdkReactNativeV3.getGoogleConsentModeStatus();
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const exportCMPInfo = (): Promise<string> => {
|
|
107
|
+
return CmSdkReactNativeV3.exportCMPInfo();
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const importCMPInfo = (cmpString: string): Promise<boolean> => {
|
|
111
|
+
return CmSdkReactNativeV3.importCMPInfo(cmpString);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const resetConsentManagementData = (): Promise<boolean> => {
|
|
115
|
+
return CmSdkReactNativeV3.resetConsentManagementData();
|
|
116
|
+
};
|
|
67
117
|
|
|
68
118
|
// Consent modification methods
|
|
69
|
-
export const acceptVendors =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
export const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
export const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
export const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
export const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
119
|
+
export const acceptVendors = (vendors: string[]): Promise<boolean> => {
|
|
120
|
+
return CmSdkReactNativeV3.acceptVendors(vendors);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const rejectVendors = (vendors: string[]): Promise<boolean> => {
|
|
124
|
+
return CmSdkReactNativeV3.rejectVendors(vendors);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const acceptPurposes = (purposes: string[], updatePurpose: boolean): Promise<boolean> => {
|
|
128
|
+
return CmSdkReactNativeV3.acceptPurposes(purposes, updatePurpose);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export const rejectPurposes = (purposes: string[], updateVendor: boolean): Promise<boolean> => {
|
|
132
|
+
return CmSdkReactNativeV3.rejectPurposes(purposes, updateVendor);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const rejectAll = (): Promise<boolean> => {
|
|
136
|
+
return CmSdkReactNativeV3.rejectAll();
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const acceptAll = (): Promise<boolean> => {
|
|
140
|
+
return CmSdkReactNativeV3.acceptAll();
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// Helper function to check if New Architecture is enabled
|
|
144
|
+
export const isNewArchitectureEnabled = (): boolean => {
|
|
145
|
+
// Check multiple indicators for New Architecture
|
|
146
|
+
// 1. Check if our module was loaded via TurboModuleRegistry
|
|
147
|
+
if (NativeCmSdkReactNativeV3 != null) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// 2. Check for bridgeless mode (official RN flag)
|
|
152
|
+
if ((global as any).RN$Bridgeless === true) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 3. Check for TurboModule interop flag
|
|
157
|
+
if ((global as any).RN$TurboInterop === true) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return false;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// Re-export types for consumer convenience
|
|
165
|
+
export type {
|
|
166
|
+
ConsentReceivedEvent,
|
|
167
|
+
ErrorEvent,
|
|
168
|
+
LinkClickEvent,
|
|
169
|
+
ATTStatusChangeEvent,
|
|
170
|
+
UrlConfig,
|
|
171
|
+
WebViewConfig,
|
|
172
|
+
UserStatus,
|
|
173
|
+
GoogleConsentModeStatus,
|
|
174
|
+
};
|
|
89
175
|
|
|
90
176
|
export default CmSdkReactNativeV3;
|