cordova-plugin-onetrust-cmp 202407.1.0 → 202407.2.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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 202407.2.1
2
+ * Fixed Android build issue with gcm.
3
+
4
+ # 202407.2.0
5
+ * Adds support for OneTrust 202407.2.0
6
+ * Updated README.md file details with the Cordova/Ionic onetrust developer portal url. Please refer to the onetrust developer portal for updated details.
7
+ * Supporting `getOTGoogleConsentModeData()` method now.
8
+
1
9
  # 202407.1.0
2
10
  * Adds support for OneTrust 202407.1.0
3
11
 
package/README-Ionic.md CHANGED
@@ -1,278 +1,3 @@
1
1
  # OneTrust CMP on Ionic
2
- ## Overview
3
- OneTrust provides a Cordova plugin that can be used in Ionic implementations as well.
4
2
 
5
- This documentation has examples in React. Capacitor is not required, but is compatible with this plugin.
6
- ## Installation
7
- ### Application Requirements
8
- For Android implementations, AndroidX must be enabled in the Android platform. For many newer Ionic/Capacitor projects, this is on by default.
9
-
10
- ### SDK Version Requirements
11
- Note that the version of the SDK must match the version of the JSON that you have published from your OneTrust instance. For example, if you have published your JSON with version 6.10.0, you must use the 6.10.0 version of the OneTrust plugin. It is recommend that a static version is specified to prevent automatic updates, as a JSON publish will need to occur with every update.
12
-
13
- ### Install Command
14
- To install the OneTrust Cordova Plugin, download the plugin locally and run the following command in your project folder, pointing to the plugin folder. This copies the contents of the plugin into your project; there's no need to maintain a separate plugin folder.
15
- #### With Cordova:
16
- ```
17
- ionic cordova plugin add cordova-plugin-onetrust-cmp@6.17.0
18
- ```
19
- #### With Capacitor:
20
- ```
21
- npm install cordova-plugin-onetrust-cmp@6.17.0
22
- npx cap sync
23
- ```
24
-
25
- #### With Cordova:
26
- ```
27
- cordova plugin cordova-plugin-onetrust update
28
- ```
29
- #### With Capacitor:
30
- ```
31
- npm update cordova-plugin-onetrust
32
- npx cap update
33
- ```
34
-
35
- ### Uninstalling
36
- To uninstall, run the following in your project folder.
37
- #### With Cordova:
38
- ```
39
- cordova plugin remove cordova-plugin-onetrust
40
- ```
41
- #### With Capacitor:
42
- ```
43
- npm uninstall cordova-plugin-onetrust
44
- npx cap sync
45
- ```
46
- # Declare OneTrust
47
- Before using any of OneTrust's methods, you will have to declare the OneTrust variable in your file, with type `any`.
48
- ```typescript
49
- declare var OneTrust:any;
50
- ```
51
- # Initialization
52
- The OneTrust SDK retrieves an object that contains all the data needed to present a UI to a User to collect consent for the SDKs used in your application. The data returned is determined by the configurations made in the OneTrust Admin console.
53
-
54
- ## `startSDK`
55
- This method is the initialization method for the SDK. It makes between 1-2 network calls, depending if an IAB2 template is fetched or not.
56
-
57
- ```typescript
58
- declare var OneTrust;
59
-
60
- OneTrust.startSDK("storageLocation","domainIdentifer","languageCode", params, (status:boolean) => {
61
- console.log("SDK Downloaded Successfully!")
62
- },(error:string) =>{
63
- console.log("SDK Failed to initialize! Error = "+error)
64
- })
65
- ```
66
- ## Arguments
67
- Argument|Description|Required|
68
- |-|-|-|
69
- |storageLocation|**String** the CDN location for the JSON that the SDK fetches.|Yes|
70
- |domainIdentifier|**String** the application GUID from the OneTrust Admin Console|Yes|
71
- |languageCode|**String** 2-digit ISO language code used to return content in a specific language|Yes
72
- |params |**JSON Object** object containing additional setup params, detailed below|No, nullable|
73
- |success|**function** Success handler once download has completed|No|
74
- |failure|**function** Failure handler if download fails |No|
75
-
76
- ## Initialization Params
77
- The values below can be placed in a JSON object and passed into the `params` argument of `startSDK` to provide additional configurations.
78
-
79
- **Example**
80
- ```javascript
81
- const params = {
82
- syncParams: {
83
- identifier: 'example@onetrust.com',
84
- syncProfileAuth:'eyJhb...',
85
- },
86
- countryCode:"US",
87
- regionCode: "CA"
88
- androidUXParams: uxJson
89
- }
90
- ```
91
-
92
- |Key|Description|
93
- |-|-|
94
- countryCode|**String** two-digit ISO country code. When specified, the OneTrust SDK will use this value as the user's geolocation.
95
- |regionCode|**String** two-digit ISO region code. When specified along with a Country Code, the OneTrust SDK will use this value as the user's geolocation.
96
- |androidUXParams|**JSON Object** JSON object representing in-app customizations for Android. See *Android - Custom styling with UXParams JSON* section.
97
- |syncParams|**JSON Object** JSON object with the user's identifier and authorization for cross-device syncing. See section below.|
98
-
99
- ## Sync Params
100
- Cross-Device Consent is an optional feature. The parameters below are not required for initializing the SDK. Each of the parameters are **required** to sync the user's consent.
101
-
102
- |Key|Description|
103
- |-|-|
104
- |identifier|**String** The identifier associated with the user for setting or retrieving consent|
105
- |setSyncProfileAuth|**String** A pre-signed JWT auth token required to perform cross-device consent.|
106
-
107
- # Display User Interfaces
108
- ## Banner
109
- The banner can be shown by calling
110
- ```typescript
111
- OneTrust.showBannerUI()
112
- ```
113
- ### Determine if a banner should be shown
114
- You can determine whether or not a banner should be shown by calling
115
- ```typescript
116
- OneTrust.shouldShowBanner((result:boolean) => {
117
- console.log("A banner should be shown = "+result)
118
- })
119
- ```
120
- This returns a boolean that determines whether or not the banner should be displayed to the user. See [this page](https://developer.onetrust.com/sdk/mobile-apps/ios/displaying-ui#shouldshowbanner) for the logic used to determine the result of `shouldShowBanner()`.
121
-
122
- **Example** <br>
123
- Below is an example of how to combine the initialization success handler with the shouldShowBanner function to automatically show a banner, if required, once the SDK download has completed.
124
-
125
- ```typescript
126
- OneTrust.startSDK(storageLocation,domainId,langCode, params, (status) =>{
127
- OneTrust.shouldShowBanner((shouldShow:boolean) => {
128
- if(status && shouldShow){
129
- OneTrust.showBannerUI()
130
- }
131
- })
132
- }, (error:string) =>{
133
- console.log(error)
134
- })
135
-
136
- ```
137
- ## Preference Center
138
- The preference center can be shown by calling
139
- ```typescript
140
- declare var OneTrust:any;
141
-
142
- OneTrust.showPreferenceCenterUI()
143
- ```
144
-
145
- ## Force Close UI
146
- If the UI needs to be dismissed programmatically, simply call
147
- ```javascript
148
- OneTrust.dismissUI()
149
- ```
150
-
151
- ## App Tracking Transparency Pre-Prompt
152
- The App Tracking Transparency Pre-Prompt can be shown by calling the below function. `OneTrust.devicePermission.idfa` is an enum for the type of permission. On Android and iOS versions < 14, requesting permission of type `ifda` will resolve a promise with a value of `-1` every time.
153
- ```javascript
154
- OneTrust.showConsentUI(window.OneTrust.devicePermission.idfa, status =>{
155
- console.log(`The new ATT Status is ${status}`)
156
- })
157
- ```
158
-
159
- ## Android - Custom styling with UXParams JSON
160
- OneTrust allows you to add custom styling to your preference center by passing in style JSON in a certain format. Build out your JSON by following the guide in the [OneTrust Developer Portal](https://developer.onetrust.com/sdk/mobile-apps/android/customize-ui).
161
-
162
- Add the JSON to the `params` argument of the `startSDK` method when initializing.
163
-
164
- ## iOS - Custom Styling with UXParams Plist
165
- Custom styling can be added to your iOS Cordova application by using a .plist file in the iOS platform code. In addition to adding the .plist file (which can be obtained from the OneTrust Demo Application) to your bundle, there are a few changes that need to be made in the platform code, outlined below. Review the guide in the [OneTrust Developer Portal](https://developer.onetrust.com/sdk/mobile-apps/ios/customize-ui).
166
-
167
- In `AppDelegate.swift`, import OTPublishersHeadlessSDK. Add an extension below the class to handle the protocol methods:
168
-
169
- ```swift
170
- import OTPublishersHeadlessSDK
171
- ...
172
- extension AppDelegate: UIConfigurator{
173
- func shouldUseCustomUIConfig() -> Bool {
174
- return true
175
- }
176
-
177
- func customUIConfigFilePath() -> String? {
178
- return Bundle.main.path(forResource: "OTSDK-UIConfig-iOS", ofType: "plist")
179
- }
180
- }
181
-
182
- ```
183
-
184
- In the `didFinishLaunchingWithOptions` protocol method, assign the AppDelegate as the UIConfigurator:
185
-
186
- ```swift
187
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
188
- // Override point for customization after application launch.
189
- OTPublishersHeadlessSDK.shared.uiConfigurator = self
190
- return true
191
- }
192
- ```
193
-
194
- ## UI Interaction Event
195
- After the UI is dismissed from your application, a document event is broadcast. You can listen for this event to detect the UI dismissed.
196
-
197
- ```typescript
198
- document.addEventListener('allSDKViewsDismissed', () =>{
199
- console.log("All OneTrust Views dismissed")
200
- }, false)
201
- ```
202
-
203
- # Get UI Data as JSON
204
- After initialization, the data used to build a preference center or banner can be retrieved easily using the following methods. Each has a success and error handler, so if the download fails and there is no cached data, errors can be handled gracefully. This can also be used to determine whether or not OneTrust has the data required to operate offline (eg. if `getBannerData` does not return an error, at least one download has completed successfully and the required data is present to render a banner.)
205
-
206
- ```javascript
207
- OneTrust.getBannerData((data) => {
208
- console.log(`Banner Data = ${JSON.stringify(data)}`)
209
- }, (error) => {
210
- console.error(`No banner data! \n Error: ${error}`)
211
- })
212
-
213
- OneTrust.getPreferenceCenterData((data) => {
214
- console.log(`Preference Center Data = ${JSON.stringify(data)}`)
215
- }, (error) => {
216
- console.error(`No Preference Center data! \n Error: ${error}`)
217
- })
218
- ```
219
-
220
- # When Consent Changes
221
- There are two ways to get consent values:
222
- * Query for Consent
223
- * Listen to events for changes
224
-
225
- ## Consent Values
226
- OneTrust universally uses the following values for consent status:
227
- |Status|Explanation|
228
- |-|-|
229
- |1|Consent Given|
230
- |0|Consent Not Given|
231
- |-1|Consent not yet gathered or SDK not initialized|
232
-
233
- ## Querying for Consent
234
- To obtain the current consent status for a category, use the `getConsentStatusForCategory` method, which returns an `Int`.
235
- ```typescript
236
- OneTrust.getConsentStatusForCategory("C0004", (status:number) => {
237
- console.log("Queried consent status for C0004 is "+status)
238
- })
239
- ```
240
-
241
- ## Listening for Consent Changes
242
- The OneTrust SDK emits events as consent statuses change. You must tell the platform code which events to listen for. Call this method for each category you wish to start observing.
243
-
244
- ```typescript
245
- OneTrust.observeChanges("C0004")
246
- ```
247
-
248
- Once a category is being observed, an event will be fired whenever the consent for that category changes. The listener carries a payload with the `categoryId` as a string and the `consentStatus` as an integer.
249
-
250
- ```typescript
251
- document.addEventListener('C0004',(payload:any) => {
252
- console.log("The new status of "+payload.categoryId+" is now"+payload.consentStatus)
253
- }, false)
254
- ```
255
-
256
- Stop listening for consent changes by calling the following for each category you'd like to cancel.
257
- ```typescript
258
- OneTrust.stopObservingChanges("C0004")
259
- ```
260
-
261
- ## Retrieving the Cached Data Subject Identifier
262
- The Data Subject Identifier that OneTrust sets can be retrieved by calling the following method. If Consent Logging is enabled, you will be able to retrieve the receipt for any consent choices made by the user inside the Consent module.
263
-
264
- ```javascript
265
- OneTrust.getCachedIdentifier((identifier) => {
266
- console.log(`Data Subject Identifier is ${identifier}.`)
267
- })
268
- ```
269
-
270
- ## Pass OneTrust Consent to a WebView
271
- If your application uses WebViews to present content and the pages rendered are running the OneTrust Cookies CMP, you can inject a JavaScript variable, provided by OneTrust, to pass consent from the native application to your WebView.
272
-
273
- The JavaScript must be evaluated before the Cookies CMP loads in the webview, therefore, it is recommended to evaluate the JS early on in the WebView load cycle.
274
- ```javascript
275
- OneTrust.getOTConsentJSForWebview((js) => {
276
- //inject javascript into webview
277
- })
278
- ```
3
+ For information on how to install and implement this package in Ionic, see our documentation here https://developer.onetrust.com/onetrust/docs/ionic
package/README.md CHANGED
@@ -1,265 +1,7 @@
1
1
  # OneTrust CMP Cordova Plugin
2
- ## Installation
3
- ### Application Requirements
4
- For Android implementations, the AndroidX dependency is required. Add the following to your `config.xml` file, inside of your Android platform tag.
5
2
 
6
- ```xml
7
- <preference name="AndroidXEnabled" value="true" />
8
- ```
3
+ For information on how to install and implement this package in Cordova, see our documentation here https://developer.onetrust.com/onetrust/docs/cordova
9
4
 
10
- ### SDK Version Requirements
11
- Note that the version of the SDK must match the version of the JSON that you have published from your OneTrust instance. For example, if you have published your JSON with version 6.10.0, you must use the 6.10.0 version of the OneTrust plugin. It is recommend that a static version is specified to prevent automatic updates, as a JSON publish will need to occur with every update.
5
+ # OneTrust CMP on Ionic
12
6
 
13
- ### Install Command
14
- To install the OneTrust Cordova Plugin, use the following command.
15
- ```
16
- cordova plugin add cordova-plugin-onetrust-cmp@6.16.0
17
- ```
18
-
19
- ### Uninstalling
20
- To uninstall, run the following in your project folder.
21
- ```
22
- cordova plugin remove cordova-plugin-onetrust-cmp
23
- ```
24
-
25
- # Initialization
26
- The OneTrust SDK retrieves an object that contains all the data needed to present a UI to a User to collect consent for the SDKs used in your application. The data returned is determined by the configurations made in the OneTrust Admin console.
27
-
28
- ## Import OneTrust
29
- OneTrust methods can be accessed via `window.OneTrust` or `cordova.plugins.OneTrust`.
30
-
31
- ## `startSDK`
32
- This method is the initialization method for the SDK. It makes between 1-2 network calls, depending if an IAB2 template is fetched or not.
33
-
34
- ```javascript
35
- window.OneTrust.startSDK(storageLocation,domainIdentifer,languageCode,params,(status) => {
36
- console.log("SDK Downloaded Successfully!")
37
- },(error) =>{
38
- console.log("SDK Failed to initialize! Error = "+error)
39
- })
40
- ```
41
- ## Arguments
42
- |Argument|Description|Required|
43
- |-|-|-|
44
- |storageLocation|**String** the CDN location for the JSON that the SDK fetches.|Yes|
45
- |domainIdentifier|**String** the application GUID from the OneTrust Admin Console|Yes|
46
- |languageCode|**String** 2-digit ISO language code used to return content in a specific language|Yes
47
- |params |**JSON Object** object containing additional setup params, detailed below|No, nullable
48
- |success|**function** Success handler once download has completed|No|
49
- |failure|**function** Failure handler if download fails |No|
50
-
51
- ## Initialization Params
52
- The values below can be placed in a JSON object and passed into the `params` argument of `startSDK` to provide additional configurations.
53
-
54
- **Example**
55
- ```javascript
56
- const params = {
57
- syncParams: {
58
- identifier: 'example@onetrust.com',
59
- syncProfileAuth:'eyJhb...',
60
- },
61
- countryCode:"US",
62
- regionCode: "CA",
63
- androidUXParams: uxJson
64
- }
65
- ```
66
-
67
- |Key|Description|
68
- |-|-|
69
- countryCode|**String** two-digit ISO country code. When specified, the OneTrust SDK will use this value as the user's geolocation.
70
- |regionCode|**String** two-digit ISO region code. When specified along with a Country Code, the OneTrust SDK will use this value as the user's geolocation.
71
- |androidUXParams|**JSON Object** JSON object representing in-app customizations for Android. See *Android - Custom styling with UXParams JSON* section.
72
- |syncParams|**JSON Object** JSON object with the user's identifier and authorization for cross-device syncing. See section below.|
73
-
74
- ## Sync Params
75
- Cross-Device Consent is an optional feature. The parameters below are not required for initializing the SDK. Each of the parameters are **required** to sync the user's consent.
76
-
77
- |Key|Description|
78
- |-|-|
79
- |identifier|**String** The identifier associated with the user for setting or retrieving consent|
80
- |setSyncProfileAuth|**String** A pre-signed JWT auth token required to perform cross-device consent.|
81
-
82
- # Display User Interfaces
83
- ## Banner
84
- The banner can be shown by calling
85
- ```javascript
86
- window.OneTrust.showBannerUI()
87
- ```
88
- ### Determine if a banner should be shown
89
- You can determine whether or not a banner should be shown by calling
90
- ```javascript
91
- window.OneTrust.shouldShowBanner((result)=>{
92
- console.log("A banner should be shown = "+result)
93
- })
94
- ```
95
- This returns a boolean that determines whether or not the banner should be displayed to the user. See [this page](https://developer.onetrust.com/sdk/mobile-apps/ios/displaying-ui#shouldshowbanner) for the logic used to determine the result of `shouldShowBanner()`.
96
-
97
- **Example** <br>
98
- Below is an example of how to combine the initialization success handler with the shouldShowBanner function to automatically show a banner, if required, once the SDK download has completed.
99
-
100
- ```javascript
101
- window.OneTrust.startSDK(storageLocation,domainId,langCode, params, (status) =>{
102
- window.OneTrust.shouldShowBanner((shouldShow) => {
103
- if(shouldShow){
104
- window.OneTrust.showBannerUI()
105
- }
106
- })
107
- }, (error) =>{
108
- console.log(error)
109
- })
110
-
111
- ```
112
- ## Preference Center
113
- The preference center can be shown by calling
114
- ```javascript
115
- window.OneTrust.showPreferenceCenterUI()
116
- ```
117
-
118
- ## Force Close UI
119
- If the UI needs to be dismissed programmatically, simply call
120
- ```javascript
121
- window.OneTrust.dismissUI()
122
- ```
123
-
124
- ## App Tracking Transparency Pre-Prompt
125
- The App Tracking Transparency Pre-Prompt can be shown by calling the below function. `OneTrust.devicePermission.idfa` is an enum for the type of permission. On Android and iOS versions < 14, requesting permission of type `ifda` will resolve a promise with a value of `-1` every time.
126
- ```javascript
127
- window.OneTrust.showConsentUI(window.OneTrust.devicePermission.idfa, status =>{
128
- console.log(`The new ATT Status is ${status}`)
129
- })
130
- ```
131
-
132
- ## Android - Custom styling with UXParams JSON
133
- OneTrust allows you to add custom styling to your preference center by passing in style JSON in a certain format. Build out your JSON by following the guide in the [OneTrust Developer Portal](https://developer.onetrust.com/sdk/mobile-apps/android/customize-ui).
134
-
135
- Add the JSON to the `params` argument of the `startSDK` method when initializing.
136
-
137
- ## iOS - Custom Styling with UXParams Plist
138
- Custom styling can be added to your iOS Cordova application by using a .plist file in the iOS platform code. In addition to adding the .plist file (which can be obtained from the OneTrust Demo Application) to your bundle, there are a few changes that need to be made in the platform code, outlined below. Review the guide in the [OneTrust Developer Portal](https://developer.onetrust.com/sdk/mobile-apps/ios/customize-ui).
139
-
140
- In `appDelegate.h`, import OTPublishersHeadlessSDK and make sure that AppDelegate conforms to the OTUIConfigurator protocol.
141
-
142
- ```obj-c
143
- #import <Cordova/CDVViewController.h>
144
- #import <Cordova/CDVAppDelegate.h>
145
- #import <OTPublishersHeadlessSDK/OTPublishersHeadlessSDK.h>
146
-
147
- @interface AppDelegate : CDVAppDelegate <OTUIConfigurator>{}
148
-
149
- @end
150
- ```
151
-
152
- In `appDelegate.m`, set the UIConfigurator to self. Then conform to the `shouldUseCustomUIConfig` and `customUIConfigFilePath` protocol methods.
153
-
154
- ```obj-c
155
-
156
- #import "AppDelegate.h"
157
- #import "MainViewController.h"
158
-
159
- @implementation AppDelegate
160
-
161
- - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
162
- {
163
- self.viewController = [[MainViewController alloc] init];
164
- [OTPublishersHeadlessSDK.shared setUiConfigurator:self]; //set UIConfigurator to Self
165
- return [super application:application didFinishLaunchingWithOptions:launchOptions];
166
- }
167
-
168
-
169
- - (BOOL)shouldUseCustomUIConfig { //conform to shouldUseCustomUIConfig
170
- return true;
171
- }
172
-
173
- - (NSString *)customUIConfigFilePath{ //conform to filepath protocol method
174
- NSString * configFile = [[NSBundle mainBundle] pathForResource:@"OTSDK-UIConfig-iOS" ofType:@"plist"]; //find path for config file
175
- return configFile;
176
- }
177
-
178
- @end
179
- ```
180
-
181
- ## UI Interaction Event
182
- After the UI is dismissed from your application, a document event is broadcast. You can listen for this event to detect the UI dismissed.
183
-
184
- ```javascript
185
- document.addEventListener('allSDKViewsDismissed', () =>{
186
- console.log("All OneTrust Views dismissed")
187
- }, false)
188
- ```
189
-
190
- # Get UI Data as JSON
191
- After initialization, the data used to build a preference center or banner can be retrieved easily using the following methods. Each has a success and error handler, so if the download fails and there is no cached data, errors can be handled gracefully. This can also be used to determine whether or not OneTrust has the data required to operate offline (eg. if `getBannerData` does not return an error, at least one download has completed successfully and the required data is present to render a banner.)
192
-
193
- ```javascript
194
- window.OneTrust.getBannerData((data) => {
195
- console.log(`Banner Data = ${JSON.stringify(data)}`)
196
- }, (error) => {
197
- console.error(`No banner data! \n Error: ${error}`)
198
- })
199
-
200
- window.OneTrust.getPreferenceCenterData((data) => {
201
- console.log(`Preference Center Data = ${JSON.stringify(data)}`)
202
- }, (error) => {
203
- console.error(`No Preference Center data! \n Error: ${error}`)
204
- })
205
- ```
206
-
207
- # When Consent Changes
208
- There are two ways to get consent values:
209
- * Query for Consent
210
- * Listen to events for changes
211
-
212
- ## Consent Values
213
- OneTrust universally uses the following values for consent status:
214
- |Status|Explanation|
215
- |-|-|
216
- |1|Consent Given|
217
- |0|Consent Not Given|
218
- |-1|Consent not yet gathered or SDK not initialized|
219
-
220
- ## Querying for Consent
221
- To obtain the current consent status for a category, use the `getConsentStatusForCategory` method, which returns an `Int`.
222
- ```javascript
223
- window.OneTrust.getConsentStatusForCategory("C0004", (status) => {
224
- console.log("Queried consent status for C0004 is "+status)
225
- })
226
- ```
227
-
228
- ## Listening for Consent Changes
229
- The OneTrust SDK emits events as consent statuses change. You must tell the platform code which events to listen for. Call this method for each category you wish to start observing.
230
-
231
- ```javascript
232
- window.OneTrust.observeChanges("C0004")
233
- ```
234
-
235
- Once a category is being observed, an event will be fired whenever the consent for that category changes. The listener carries a payload with the `categoryId` as a string and the `consentStatus` as an integer.
236
-
237
- ```javascript
238
- document.addEventListener('C0004',(payload) => {
239
- console.log("The new status of "+payload.categoryId+" is now"+payload.consentStatus)
240
- }, false)
241
- ```
242
-
243
- Stop listening for consent changes by calling the following for each category you'd like to cancel.
244
- ```javascript
245
- window.OneTrust.stopObservingChanges("C0004")
246
- ```
247
-
248
- ## Retrieving the Cached Data Subject Identifier
249
- The Data Subject Identifier that OneTrust sets can be retrieved by calling the following method. If Consent Logging is enabled, you will be able to retrieve the receipt for any consent choices made by the user inside the Consent module.
250
-
251
- ```javascript
252
- window.OneTrust.getCachedIdentifier((identifier) => {
253
- console.log(`Data Subject Identifier is ${identifier}.`)
254
- })
255
- ```
256
-
257
- ## Pass OneTrust Consent to a WebView
258
- If your application uses WebViews to present content and the pages rendered are running the OneTrust Cookies CMP, you can inject a JavaScript variable, provided by OneTrust, to pass consent from the native application to your WebView.
259
-
260
- The JavaScript must be evaluated before the Cookies CMP loads in the webview, therefore, it is recommended to evaluate the JS early on in the WebView load cycle.
261
- ```javascript
262
- window.OneTrust.getOTConsentJSForWebview((js) => {
263
- //inject javascript into webview
264
- })
265
- ```
7
+ For information on how to install and implement this package in Ionic, see our documentation here https://developer.onetrust.com/onetrust/docs/ionic
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-onetrust-cmp",
3
- "version": "202407.1.0",
3
+ "version": "202407.2.1",
4
4
  "description": "OneTrust is the leading Consent Management solution provider. This plugin exposes OneTrust's native CMP functionality to Cordova and Ionic environments.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="cordova-plugin-onetrust-cmp" version="202407.1.0"
2
+ <plugin id="cordova-plugin-onetrust-cmp" version="202407.2.1"
3
3
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  xmlns:android="http://schemas.android.com/apk/res/android">
5
5
  <name>OneTrust</name>
@@ -18,12 +18,12 @@
18
18
  <config>
19
19
  </config>
20
20
  <pods use-frameworks="true">
21
- <pod name="OneTrust-CMP-XCFramework" spec="~> 202407.1.0.0" />
21
+ <pod name="OneTrust-CMP-XCFramework" spec="~> 202407.2.0.0" />
22
22
  </pods>
23
23
  </podspec>
24
24
  </platform>
25
25
  <platform name="android">
26
- <framework src="com.onetrust.cmp:native-sdk:202407.1.0.0" />
26
+ <framework src="com.onetrust.cmp:native-sdk:202407.2.0.0" />
27
27
  <framework src="androidx.appcompat:appcompat:1.2.0" />
28
28
  <config-file parent="/*" target="res/xml/config.xml">
29
29
  <feature name="OneTrust">
@@ -13,6 +13,7 @@ import com.onetrust.otpublishers.headless.Public.OTPublishersHeadlessSDK;
13
13
  import com.onetrust.otpublishers.headless.Public.Response.OTResponse;
14
14
  import com.onetrust.otpublishers.headless.Public.DataModel.OTSdkParams;
15
15
  import com.onetrust.otpublishers.headless.Public.DataModel.OTUXParams;
16
+ import com.onetrust.otpublishers.headless.gcm.consent.OTGoogleConsentModeData;
16
17
 
17
18
  import org.apache.cordova.CordovaInterface;
18
19
  import org.apache.cordova.CordovaPlugin;
@@ -87,6 +88,9 @@ public class OneTrust extends CordovaPlugin{
87
88
  case "dismissUI":
88
89
  dismissUI();
89
90
  return true;
91
+ case "getOTGoogleConsentModeData":
92
+ getOTGoogleConsentModeData(callbackContext);
93
+ return true;
90
94
  default:
91
95
  callbackContext.error("Unimplemented method called");
92
96
  break;
@@ -335,4 +339,31 @@ public class OneTrust extends CordovaPlugin{
335
339
  emit("allSDKViewsDismissed","{}");
336
340
  }
337
341
  }
342
+
343
+ private void getOTGoogleConsentModeData(CallbackContext callbackContext) throws JSONException {
344
+ Runnable runnable = new Runnable() {
345
+ @Override
346
+ public void run() {
347
+ OTGoogleConsentModeData otGoogleConsentModeData = ot.getOTGoogleConsentModeData();
348
+ if(otGoogleConsentModeData != null){
349
+ JSONObject googleConsentData = new JSONObject();
350
+ try {
351
+ googleConsentData.put("analytics_storage", otGoogleConsentModeData.getConsentType().getAnalyticsStorage());
352
+ googleConsentData.put("ad_storage", otGoogleConsentModeData.getConsentType().getAdStorage());
353
+ googleConsentData.put("ad_user_data", otGoogleConsentModeData.getConsentType().getAdUserData());
354
+ googleConsentData.put("ad_personalization", otGoogleConsentModeData.getConsentType().getAdPersonalization());
355
+ googleConsentData.put("functionality_storage", otGoogleConsentModeData.getConsentType().getFunctionalityStorage());
356
+ googleConsentData.put("personalization_storage", otGoogleConsentModeData.getConsentType().getPersonalizationStorage());
357
+ googleConsentData.put("security_storage", otGoogleConsentModeData.getConsentType().getSecurityStorage());
358
+ } catch (Exception e) {
359
+
360
+ }
361
+ callbackContext.success(googleConsentData);
362
+ }else{
363
+ callbackContext.error("getOTGoogleConsentModeData not found.");
364
+ }
365
+ }
366
+ };
367
+ runInThreadPool(runnable);
368
+ }
338
369
  }
@@ -203,6 +203,32 @@ import AppTrackingTransparency
203
203
  }
204
204
  self.returnToCordova(pluginResult: pluginResult, command: command)
205
205
  }
206
+
207
+ @objc(getOTGoogleConsentModeData:)
208
+ func getOTGoogleConsentModeData(_ command:CDVInvokedUrlCommand){
209
+ var pluginResult = CDVPluginResult(status: CDVCommandStatus_ERROR)
210
+ let gcmOTData = OTPublishersHeadlessSDK.shared.getOTGoogleConsentModeData()
211
+ let analyticsStorageValue = gcmOTData.consentType.analyticsStorage == .granted ? "granted" : "denied"
212
+ let addStorageValue = gcmOTData.consentType.adStorage == .granted ? "granted" : "denied"
213
+ let adUserDataValue = gcmOTData.consentType.adUserData == .granted ? "granted" : "denied"
214
+ let adPersonalizationValue = gcmOTData.consentType.adPersonalization == .granted ? "granted" : "denied"
215
+ let functionalityStorageValue = gcmOTData.consentType.functionalityStorage == .granted ? "granted" : "denied"
216
+ let personalizationStorageValue = gcmOTData.consentType.personalizationStorage == .granted ? "granted" : "denied"
217
+ let securityStorageValue = gcmOTData.consentType.securityStorage == .granted ? "granted" : "denied"
218
+
219
+ let gcmOTDataJSONObject: [String: String] = [
220
+ "analytics_storage": analyticsStorageValue,
221
+ "ad_storage": addStorageValue,
222
+ "ad_user_data": adUserDataValue,
223
+ "ad_personalization": adPersonalizationValue,
224
+ "functionality_storage": functionalityStorageValue,
225
+ "personalization_storage": personalizationStorageValue,
226
+ "security_storage": securityStorageValue
227
+ ]
228
+
229
+ pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: gcmOTDataJSONObject)
230
+ self.returnToCordova(pluginResult: pluginResult, command: command)
231
+ }
206
232
 
207
233
  @objc(getOTConsentJSForWebview:)
208
234
  func getOTConsentJSForWebview(_ command:CDVInvokedUrlCommand){
package/www/OneTrust.js CHANGED
@@ -63,6 +63,10 @@ var exports = {
63
63
  exec(null, null, pluginName, 'dismissUI')
64
64
  },
65
65
 
66
+ getOTGoogleConsentModeData: (success, error) => {
67
+ exec(success,error, pluginName, 'getOTGoogleConsentModeData')
68
+ },
69
+
66
70
  devicePermission: Object.freeze({idfa:0})
67
71
  }
68
72