@commandersact/tcconsent-react-native 1.4.2-beta.42
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/LICENSE +20 -0
- package/README.md +112 -0
- package/android/build.gradle +93 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/tcconsentreactnative/TCConsentReactNativeGenerated.java +10 -0
- package/android/src/main/java/com/tcconsentreactnative/TcconsentReactNativeModule.java +460 -0
- package/android/src/main/java/com/tcconsentreactnative/TcconsentReactNativePackage.java +28 -0
- package/android/src/main/proguard-rules.pro +2 -0
- package/ios/TCConsentGenerated.swift +10 -0
- package/ios/TcconsentReactNative-Bridging-Header.h +2 -0
- package/ios/TcconsentReactNative.mm +48 -0
- package/ios/TcconsentReactNative.swift +331 -0
- package/lib/commonjs/TCConsent.js +190 -0
- package/lib/commonjs/TCConsent.js.map +1 -0
- package/lib/commonjs/TCConsentAPI.js +125 -0
- package/lib/commonjs/TCConsentAPI.js.map +1 -0
- package/lib/commonjs/index.js +28 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/TCConsent.js +164 -0
- package/lib/module/TCConsent.js.map +1 -0
- package/lib/module/TCConsentAPI.js +118 -0
- package/lib/module/TCConsentAPI.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/TCConsent.d.ts +74 -0
- package/lib/typescript/TCConsent.d.ts.map +1 -0
- package/lib/typescript/TCConsentAPI.d.ts +82 -0
- package/lib/typescript/TCConsentAPI.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +177 -0
- package/src/TCConsent.tsx +225 -0
- package/src/TCConsentAPI.tsx +131 -0
- package/src/index.tsx +2 -0
- package/tcconsent-react-native-swift.podspec +28 -0
- package/tcconsent-react-native.podspec +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 CommandersAct
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# tcconsent-react-native
|
|
2
|
+
|
|
3
|
+
CommandersAct's TCConsent react native bridge
|
|
4
|
+
|
|
5
|
+
# 1. Installation
|
|
6
|
+
|
|
7
|
+
### 1.1 Package.json
|
|
8
|
+
|
|
9
|
+
add the following dependencies into your package.json, and then install them using `npm install`
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
"tcconsent-react-native": "git+https://github.com/commandersact/tcconsent-react-native#*.*.*", #check latest available version
|
|
13
|
+
"tccore-react-native": "git+https://github.com/commandersact/tccore-react-native#*.*.*", #check latest available version
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### 1.2 Podfile - iOS Specific
|
|
17
|
+
|
|
18
|
+
Once the JS packages installed, you'll need to manually add the required pods to your Podfile:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
pod "tccore-react-native-swift", :path => '../node_modules/@commandersact/tccore-react-native/tccore-react-native-swift.podspec'
|
|
22
|
+
pod "tcserverside-react-native-swift", :path => '../node_modules/@commandersact/tcserverside-react-native/tcserverside-react-native-swift.podspec'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
check the demo app podfile here : https://github.com/CommandersAct/TCDemoReactNative/blob/master/ios/Podfile
|
|
26
|
+
|
|
27
|
+
After updating the Podfile, navigate to your ios/ directory and run:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
pod install
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This ensures that the native modules are correctly integrated into your Xcode project.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### 1.3 Jsons files
|
|
37
|
+
|
|
38
|
+
Depending on your use case, you may need one or multiple of these offline jsons in both of your android/iOS native app code.
|
|
39
|
+
|
|
40
|
+
- privacy.json [if you are planning on using our consent interface/ Privacy center]
|
|
41
|
+
- vendor-list.json if your are using IAB.
|
|
42
|
+
- purposes-xx.json if you are using IAB with a translation.
|
|
43
|
+
- google-atp-list.json if you wanna use ACString.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
#### For Android :
|
|
47
|
+
|
|
48
|
+
Your should have all of your necessary json files inside the assets folder of your main app module.
|
|
49
|
+
|
|
50
|
+
#### For iOS :
|
|
51
|
+
|
|
52
|
+
Make sure all your necessary json files are bundled with your app main bundle.
|
|
53
|
+
Xcode target -> Build phases -> copy bundle ressources.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## 2. Usage
|
|
57
|
+
|
|
58
|
+
Usage will highly depend on your usecase. It is highly recommanded to have a look on the native SDK documentation for more insights and details. [Android](https://github.com/CommandersAct/androidV5/tree/master/TCConsent) and [iOS](https://github.com/CommandersAct/iOSV5/tree/master/TCConsent).
|
|
59
|
+
|
|
60
|
+
The follwing is a code sample for some main methodes of the library :
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
// imports ...
|
|
64
|
+
import * as TCConsent from 'tcconsent-react-native';
|
|
65
|
+
// Initialisation ..
|
|
66
|
+
TCConsent.setSiteIDPrivacyID(3311, 2929)
|
|
67
|
+
// Show privacy center
|
|
68
|
+
TCConsent.showPrivacyCenter()
|
|
69
|
+
// Accept consent directly without displaying the privacy center
|
|
70
|
+
TCConsent.acceptAllConsent()
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 3. Demo App
|
|
75
|
+
|
|
76
|
+
Check the following repo for a full working react-native app that integrates this library.
|
|
77
|
+
|
|
78
|
+
https://github.com/CommandersAct/TCDemoReactNative
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### 4. iOS Build Issues Fix Guide
|
|
82
|
+
|
|
83
|
+
On iOS, library linking can be fragile and files may easily break or become corrupted. If you encounter strange dependency issues, _OBJ_CLASS_$__ errors, or “not found” build failures, try the following steps:
|
|
84
|
+
|
|
85
|
+
1- Delete your node_modules folder
|
|
86
|
+
|
|
87
|
+
2- Remove package-lock.json
|
|
88
|
+
|
|
89
|
+
3- Close Xcode if it’s open
|
|
90
|
+
|
|
91
|
+
4- Run npm install to reinstall dependencies
|
|
92
|
+
|
|
93
|
+
5- Delete ios/Podfile.lock
|
|
94
|
+
|
|
95
|
+
6- Remove the ios/Pods folder
|
|
96
|
+
|
|
97
|
+
7- Ensure your Podfile is correctly configured—verify that required pods (e.g., pod "tccore-...") are properly declared
|
|
98
|
+
|
|
99
|
+
8- Run pod install inside the ios/ directory
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
8.1- In some cases, you may also need to open Xcode, clean the build folder, and run the app from the .xcworkspace file.
|
|
103
|
+
|
|
104
|
+
# Support & Contact :
|
|
105
|
+
|
|
106
|
+
Support : support@commandersact.com
|
|
107
|
+
|
|
108
|
+
http://www.commandersact.com
|
|
109
|
+
|
|
110
|
+
Commanders Act | 7b rue taylor - 75010 PARIS - France
|
|
111
|
+
|
|
112
|
+

|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
def isNewArchitectureEnabled() {
|
|
13
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
apply plugin: "com.android.library"
|
|
17
|
+
|
|
18
|
+
if (isNewArchitectureEnabled()) {
|
|
19
|
+
apply plugin: "com.facebook.react"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
def getExtOrDefault(name) {
|
|
23
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["TcconsentReactNative_" + name]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
def getExtOrIntegerDefault(name) {
|
|
27
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["TcconsentReactNative_" + name]).toInteger()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
def supportsNamespace() {
|
|
31
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
32
|
+
def major = parsed[0].toInteger()
|
|
33
|
+
def minor = parsed[1].toInteger()
|
|
34
|
+
|
|
35
|
+
// Namespace support was added in 7.3.0
|
|
36
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
android {
|
|
40
|
+
if (supportsNamespace()) {
|
|
41
|
+
namespace "com.tcconsentreactnative"
|
|
42
|
+
|
|
43
|
+
defaultConfig {
|
|
44
|
+
consumerProguardFiles 'src/main/proguard-rules.pro'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
sourceSets {
|
|
48
|
+
main {
|
|
49
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
55
|
+
|
|
56
|
+
defaultConfig {
|
|
57
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
58
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
buildTypes {
|
|
63
|
+
release {
|
|
64
|
+
minifyEnabled false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
lintOptions {
|
|
69
|
+
disable "GradleCompatible"
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
compileOptions {
|
|
73
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
74
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
repositories {
|
|
79
|
+
mavenCentral()
|
|
80
|
+
google()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
dependencies {
|
|
85
|
+
// For < 0.71, this will be from the local maven repo
|
|
86
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
87
|
+
//noinspection GradleDynamicVersion
|
|
88
|
+
implementation 'com.facebook.react:react-native:+'
|
|
89
|
+
implementation 'com.tagcommander.lib:core:5.4.9'
|
|
90
|
+
implementation 'com.tagcommander.lib:Consent:5.3.10'
|
|
91
|
+
implementation 'com.tagcommander.lib:TCIAB:5.1.1'
|
|
92
|
+
}
|
|
93
|
+
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
package com.tcconsentreactnative;
|
|
2
|
+
|
|
3
|
+
import static com.tagcommander.lib.consent.TCConsentConstants.kTCStartWithPurposeScreen;
|
|
4
|
+
import static com.tagcommander.lib.consent.TCConsentConstants.kTCStartWithVendorScreen;
|
|
5
|
+
|
|
6
|
+
import android.content.Intent;
|
|
7
|
+
import android.util.Log;
|
|
8
|
+
|
|
9
|
+
import androidx.annotation.NonNull;
|
|
10
|
+
|
|
11
|
+
import com.facebook.react.bridge.Arguments;
|
|
12
|
+
import com.facebook.react.bridge.Promise;
|
|
13
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
14
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
15
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
16
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
17
|
+
import com.facebook.react.bridge.WritableArray;
|
|
18
|
+
import com.facebook.react.bridge.WritableMap;
|
|
19
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
20
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
21
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
22
|
+
import com.tagcommander.lib.consent.ETCConsentAction;
|
|
23
|
+
import com.tagcommander.lib.consent.ETCConsentSource;
|
|
24
|
+
import com.tagcommander.lib.consent.TCConsent;
|
|
25
|
+
import com.tagcommander.lib.consent.TCConsentAPI;
|
|
26
|
+
import com.tagcommander.lib.consent.TCConsentConstants;
|
|
27
|
+
import com.tagcommander.lib.consent.TCPrivacyCallbacks;
|
|
28
|
+
import com.tagcommander.lib.consent.TCPrivacyCenter;
|
|
29
|
+
import com.tagcommander.lib.core.TCDebug;
|
|
30
|
+
import com.tagcommander.lib.core.TCLogger;
|
|
31
|
+
import com.tagcommander.lib.core.TCUser;
|
|
32
|
+
|
|
33
|
+
import org.json.JSONException;
|
|
34
|
+
|
|
35
|
+
import java.util.HashMap;
|
|
36
|
+
import java.util.List;
|
|
37
|
+
import java.util.Map;
|
|
38
|
+
|
|
39
|
+
@ReactModule(name = TcconsentReactNativeModule.NAME)
|
|
40
|
+
public class TcconsentReactNativeModule extends ReactContextBaseJavaModule implements TCPrivacyCallbacks
|
|
41
|
+
{
|
|
42
|
+
public static final String NAME = "TcconsentReactNative";
|
|
43
|
+
|
|
44
|
+
public TcconsentReactNativeModule(ReactApplicationContext reactContext) {
|
|
45
|
+
super(reactContext);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@Override
|
|
49
|
+
@NonNull
|
|
50
|
+
public String getName() {
|
|
51
|
+
return NAME;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@ReactMethod
|
|
55
|
+
public void setSiteIDPrivacyID(double siteID, double privacyID)
|
|
56
|
+
{
|
|
57
|
+
TCDebug.setDebugLevel(Log.VERBOSE);
|
|
58
|
+
TCConsent.getInstance().registerCallback(this);
|
|
59
|
+
TCConsent.getInstance().setSiteIDPrivacyIDAppContext((int) siteID, (int) privacyID, getReactApplicationContext());
|
|
60
|
+
refreshTCUser();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@ReactMethod
|
|
64
|
+
public void acceptAllConsent()
|
|
65
|
+
{
|
|
66
|
+
TCConsent.getInstance().acceptAllConsent();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@ReactMethod
|
|
70
|
+
public void refuseAllConsent()
|
|
71
|
+
{
|
|
72
|
+
TCConsent.getInstance().refuseAllConsent();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@ReactMethod
|
|
76
|
+
public void showPrivacyCenter(String startScreen, String customTitle)
|
|
77
|
+
{
|
|
78
|
+
Intent PCM = new Intent(getReactApplicationContext(), TCPrivacyCenter.class);
|
|
79
|
+
setStartScreen(PCM, startScreen);
|
|
80
|
+
PCM.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
81
|
+
getReactApplicationContext().startActivity(PCM);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@ReactMethod
|
|
85
|
+
public void useACString(boolean value)
|
|
86
|
+
{
|
|
87
|
+
TCConsent.getInstance().useAcString(value);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@ReactMethod
|
|
91
|
+
public void customPCMSetSiteID(double siteID, double privacyID)
|
|
92
|
+
{
|
|
93
|
+
TCConsent.getInstance().registerCallback(this);
|
|
94
|
+
TCConsent.getInstance().initWithCustomPCM((int) siteID, (int) privacyID, getReactApplicationContext());
|
|
95
|
+
refreshTCUser();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@ReactMethod
|
|
99
|
+
public void setConsentDuration(double months)
|
|
100
|
+
{
|
|
101
|
+
TCConsent.getInstance().setConsentDuration((float) months);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@ReactMethod
|
|
105
|
+
public void useCustomPublisherRestrictions()
|
|
106
|
+
{
|
|
107
|
+
TCConsent.getInstance().useCustomPublisherRestrictions();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@ReactMethod
|
|
111
|
+
public void saveConsentFromPopUp(ReadableMap consent)
|
|
112
|
+
{
|
|
113
|
+
TCConsent.getInstance().saveConsentFromPopUp(convertReadableMapToHashMap(consent));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@ReactMethod
|
|
117
|
+
public void saveConsent(ReadableMap consent)
|
|
118
|
+
{
|
|
119
|
+
TCConsent.getInstance().saveConsent(convertReadableMapToHashMap(consent));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@ReactMethod
|
|
123
|
+
public void saveConsentFromConsentSourceWithPrivacyAction(ReadableMap consent, String source, String action)
|
|
124
|
+
{
|
|
125
|
+
TCConsent.getInstance().saveConsentFromConsentSourceWithPrivacyAction(convertReadableMapToHashMap(consent),
|
|
126
|
+
evaluateConsentSource(source),
|
|
127
|
+
evaluateConsentAction(action));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@ReactMethod
|
|
131
|
+
public void statEnterPCToVendorScreen()
|
|
132
|
+
{
|
|
133
|
+
TCConsent.getInstance().statEnterPCToVendorScreen();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@ReactMethod
|
|
137
|
+
public void statShowVendorScreen()
|
|
138
|
+
{
|
|
139
|
+
TCConsent.getInstance().statShowVendorScreen();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@ReactMethod
|
|
143
|
+
public void statViewPrivacyPoliciesFromPrivacyCenter()
|
|
144
|
+
{
|
|
145
|
+
TCConsent.getInstance().statViewPrivacyPoliciesFromPrivacyCenter();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@ReactMethod
|
|
149
|
+
public void statViewPrivacyCenter()
|
|
150
|
+
{
|
|
151
|
+
TCConsent.getInstance().statViewPrivacyCenter();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@ReactMethod
|
|
155
|
+
public void statViewBanner()
|
|
156
|
+
{
|
|
157
|
+
TCConsent.getInstance().statViewBanner();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@ReactMethod
|
|
161
|
+
public void statViewPrivacyPoliciesFromBanner()
|
|
162
|
+
{
|
|
163
|
+
TCConsent.getInstance().statViewPrivacyPoliciesFromBanner();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@ReactMethod
|
|
167
|
+
public void consentAsJson(Promise promise)
|
|
168
|
+
{
|
|
169
|
+
String rawJson = TCConsent.getInstance().getConsentAsJson();
|
|
170
|
+
String consentAsJson = (rawJson != null) ? rawJson : "";
|
|
171
|
+
promise.resolve(consentAsJson);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@ReactMethod
|
|
175
|
+
public void resetSavedConsent()
|
|
176
|
+
{
|
|
177
|
+
TCConsent.getInstance().resetSavedConsent();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@ReactMethod
|
|
181
|
+
public void setLanguage(String languageCode)
|
|
182
|
+
{
|
|
183
|
+
TCConsent.getInstance().setLanguage(languageCode);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@Override
|
|
187
|
+
public void consentOutdated()
|
|
188
|
+
{
|
|
189
|
+
getReactApplicationContext()
|
|
190
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
191
|
+
.emit("consentOutdated", null);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@Override
|
|
195
|
+
public void consentUpdated(Map<String, String> consent)
|
|
196
|
+
{
|
|
197
|
+
refreshTCUser();
|
|
198
|
+
getReactApplicationContext()
|
|
199
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
200
|
+
.emit("consentUpdated", mapToReadableMap(consent));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@Override
|
|
204
|
+
public void consentCategoryChanged()
|
|
205
|
+
{
|
|
206
|
+
getReactApplicationContext()
|
|
207
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
208
|
+
.emit("consentCategoryChanged", null);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
@Override
|
|
212
|
+
public void significantChangesInPrivacy()
|
|
213
|
+
{
|
|
214
|
+
getReactApplicationContext()
|
|
215
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
216
|
+
.emit("significantChangesInPrivacy", null);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private void refreshTCUser()
|
|
220
|
+
{
|
|
221
|
+
String userJson = "";
|
|
222
|
+
try
|
|
223
|
+
{
|
|
224
|
+
userJson = TCUser.getInstance().getJsonObject()
|
|
225
|
+
.put("consentID", TCUser.getInstance().consentID)
|
|
226
|
+
.put("consent_categories", TCUser.getInstance().getConsentCategories())
|
|
227
|
+
.put("consent_vendors", TCUser.getInstance().getConsentVendors())
|
|
228
|
+
.put("external_consent", TCUser.getInstance().getExternalConsent())
|
|
229
|
+
.toString();
|
|
230
|
+
}
|
|
231
|
+
catch (JSONException e)
|
|
232
|
+
{
|
|
233
|
+
e.printStackTrace();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
getReactApplicationContext()
|
|
237
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
238
|
+
.emit("refreshTCUser", userJson);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
private HashMap<String, String> convertReadableMapToHashMap(ReadableMap readableMap)
|
|
242
|
+
{
|
|
243
|
+
HashMap<String, String> hashMap = new HashMap<>();
|
|
244
|
+
|
|
245
|
+
if (readableMap == null)
|
|
246
|
+
{
|
|
247
|
+
return hashMap;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
for (String key : readableMap.toHashMap().keySet())
|
|
251
|
+
{
|
|
252
|
+
if (readableMap.hasKey(key) && !readableMap.isNull(key))
|
|
253
|
+
{
|
|
254
|
+
hashMap.put(key, readableMap.getString(key));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return hashMap;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
private ETCConsentSource evaluateConsentSource(String stringSource)
|
|
262
|
+
{
|
|
263
|
+
if (stringSource.equals("POP_UP"))
|
|
264
|
+
{
|
|
265
|
+
return ETCConsentSource.Popup;
|
|
266
|
+
}
|
|
267
|
+
else
|
|
268
|
+
{
|
|
269
|
+
return ETCConsentSource.PrivacyCenter;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
private ETCConsentAction evaluateConsentAction(String stringAction)
|
|
274
|
+
{
|
|
275
|
+
if (stringAction.equals("ACCEPT_ALL"))
|
|
276
|
+
{
|
|
277
|
+
return ETCConsentAction.AcceptAll;
|
|
278
|
+
}
|
|
279
|
+
else if (stringAction.equals("REFUSE_ALL"))
|
|
280
|
+
{
|
|
281
|
+
return ETCConsentAction.RefuseAll;
|
|
282
|
+
}
|
|
283
|
+
else
|
|
284
|
+
{
|
|
285
|
+
return ETCConsentAction.Save;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
private String getTCUserJson()
|
|
290
|
+
{
|
|
291
|
+
try
|
|
292
|
+
{
|
|
293
|
+
return TCUser.getInstance().getJsonObject().put("consentID", TCUser.getInstance().consentID).toString();
|
|
294
|
+
}
|
|
295
|
+
catch (JSONException e)
|
|
296
|
+
{
|
|
297
|
+
e.printStackTrace();
|
|
298
|
+
}
|
|
299
|
+
return "";
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private WritableMap mapToReadableMap(Map<String, String> inputMap)
|
|
303
|
+
{
|
|
304
|
+
WritableMap writableMap = new WritableNativeMap();
|
|
305
|
+
|
|
306
|
+
try
|
|
307
|
+
{
|
|
308
|
+
for (Map.Entry<String, String> entry : inputMap.entrySet())
|
|
309
|
+
{
|
|
310
|
+
writableMap.putString(entry.getKey(), entry.getValue());
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
catch (Exception e)
|
|
314
|
+
{
|
|
315
|
+
TCLogger.getInstance().logMessage("CONVERSION_ERROR : Error converting Map to ReadableMap", Log.ERROR);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return writableMap;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
@ReactMethod
|
|
322
|
+
public void addListener(String eventName) {}
|
|
323
|
+
|
|
324
|
+
@ReactMethod
|
|
325
|
+
public void removeListeners(Integer count) {}
|
|
326
|
+
|
|
327
|
+
private void setStartScreen(Intent pcm, String startScreen)
|
|
328
|
+
{
|
|
329
|
+
if (startScreen != null && startScreen.equals(kTCStartWithPurposeScreen))
|
|
330
|
+
{
|
|
331
|
+
pcm.putExtra(TCConsentConstants.kTCPC_START_SCREEN, kTCStartWithPurposeScreen);
|
|
332
|
+
}
|
|
333
|
+
else if (startScreen != null && startScreen.equals(kTCStartWithVendorScreen))
|
|
334
|
+
{
|
|
335
|
+
pcm.putExtra(TCConsentConstants.kTCPC_START_SCREEN, kTCStartWithVendorScreen);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
@ReactMethod
|
|
340
|
+
public void isConsentAlreadyGiven(Promise promise)
|
|
341
|
+
{
|
|
342
|
+
promise.resolve(TCConsentAPI.isConsentAlreadyGiven(getReactApplicationContext()));
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
@ReactMethod
|
|
346
|
+
public void getLastTimeConsentWasSaved(Promise promise)
|
|
347
|
+
{
|
|
348
|
+
promise.resolve(TCConsentAPI.getLastTimeConsentWasSaved(getReactApplicationContext()).toString());
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
@ReactMethod
|
|
352
|
+
public void isCategoryAccepted(Double ID, Promise promise)
|
|
353
|
+
{
|
|
354
|
+
promise.resolve(TCConsentAPI.isCategoryAccepted(ID.intValue(), getReactApplicationContext()));
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
@ReactMethod
|
|
358
|
+
public void isVendorAccepted(Double ID, Promise promise)
|
|
359
|
+
{
|
|
360
|
+
promise.resolve(TCConsentAPI.isVendorAccepted(ID.intValue(), getReactApplicationContext()));
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
@ReactMethod
|
|
364
|
+
public void isIABPurposeAccepted(Double ID, Promise promise)
|
|
365
|
+
{
|
|
366
|
+
promise.resolve(TCConsentAPI.isIABPurposeAccepted(ID.intValue(), getReactApplicationContext()));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
@ReactMethod
|
|
370
|
+
public void isIABVendorAccepted(Double ID, Promise promise)
|
|
371
|
+
{
|
|
372
|
+
promise.resolve(TCConsentAPI.isIABVendorAccepted(ID.intValue(), getReactApplicationContext()));
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
@ReactMethod
|
|
376
|
+
public void isIABSpecialFeatureAccepted(Double ID, Promise promise)
|
|
377
|
+
{
|
|
378
|
+
promise.resolve(TCConsentAPI.isIABSpecialFeatureAccepted(ID.intValue(), getReactApplicationContext()));
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
@ReactMethod
|
|
382
|
+
public void getAcceptedCategories(Promise promise)
|
|
383
|
+
{
|
|
384
|
+
promise.resolve(toWritableStringArray(TCConsentAPI.getAcceptedCategories(getReactApplicationContext())));
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
@ReactMethod
|
|
388
|
+
public void getAcceptedVendors(Promise promise)
|
|
389
|
+
{
|
|
390
|
+
promise.resolve(toWritableStringArray(TCConsentAPI.getAcceptedVendors(getReactApplicationContext())));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
@ReactMethod
|
|
394
|
+
public void getAcceptedGoogleVendors(Promise promise)
|
|
395
|
+
{
|
|
396
|
+
promise.resolve(toWritableStringArray(TCConsentAPI.getAcceptedGoogleVendors(getReactApplicationContext())));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
@ReactMethod
|
|
400
|
+
public void getAllAcceptedConsent(Promise promise)
|
|
401
|
+
{
|
|
402
|
+
promise.resolve(toWritableStringArray(TCConsentAPI.getAllAcceptedConsent(getReactApplicationContext())));
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
@ReactMethod
|
|
406
|
+
public void shouldDisplayPrivacyCenter(Promise promise)
|
|
407
|
+
{
|
|
408
|
+
promise.resolve(TCConsentAPI.shouldDisplayPrivacyCenter(getReactApplicationContext()));
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* function not available for this version, needs native Android SDK changes
|
|
413
|
+
*
|
|
414
|
+
@ReactMethod
|
|
415
|
+
public void switchDefaultState(boolean value)
|
|
416
|
+
{
|
|
417
|
+
TCConsent.getInstance().switchDefaultState = value;
|
|
418
|
+
}
|
|
419
|
+
**/
|
|
420
|
+
|
|
421
|
+
@ReactMethod
|
|
422
|
+
public void deactivateBackButton(boolean value)
|
|
423
|
+
{
|
|
424
|
+
TCConsent.getInstance().deactivateBackButton = value;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* function not available for this version, needs native Android SDK changes
|
|
429
|
+
*
|
|
430
|
+
@ReactMethod
|
|
431
|
+
public void do_not_track(boolean value)
|
|
432
|
+
{
|
|
433
|
+
TCConsent.getInstance().do_not_track = value;
|
|
434
|
+
}
|
|
435
|
+
**/
|
|
436
|
+
|
|
437
|
+
@ReactMethod
|
|
438
|
+
public void setConsentVersion(String value)
|
|
439
|
+
{
|
|
440
|
+
TCConsent.getInstance().consentVersion = value;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
@ReactMethod
|
|
444
|
+
public void getConsentVersion(Promise promise)
|
|
445
|
+
{
|
|
446
|
+
promise.resolve(TCConsent.getInstance().consentVersion);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
public static WritableArray toWritableStringArray(List<String> array)
|
|
450
|
+
{
|
|
451
|
+
WritableArray writableArray = Arguments.createArray();
|
|
452
|
+
|
|
453
|
+
for (int i = 0; i < array.size(); i++)
|
|
454
|
+
{
|
|
455
|
+
writableArray.pushString(array.get(i));
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
return writableArray;
|
|
459
|
+
}
|
|
460
|
+
}
|