cordova-plugin-onetrust-cmp 202603.1.0 → 202604.1.0

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,7 @@
1
+ ## 202604.1.0
2
+ * Adds support for OneTrust 202604.1.0
3
+ * Added renameProfile, fetchBannerCmpApiData, fetchPreferencesCmpApiData, fetchVendorsCmpApiData methods
4
+
1
5
  ## 202603.1.0
2
6
  * Exposed OTConsentUpdated event
3
7
  * Adds support for OneTrust 202603.1.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-onetrust-cmp",
3
- "version": "202603.1.0",
3
+ "version": "202604.1.0",
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="202603.1.0"
2
+ <plugin id="cordova-plugin-onetrust-cmp" version="202604.1.0"
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="~> 202603.1.0.0" />
21
+ <pod name="OneTrust-CMP-XCFramework" spec="~> 202604.1.0.0" />
22
22
  </pods>
23
23
  </podspec>
24
24
  </platform>
25
25
  <platform name="android">
26
- <framework src="com.onetrust.cmp:native-sdk:202603.1.0.0" />
26
+ <framework src="com.onetrust.cmp:native-sdk:202604.1.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">
@@ -5,6 +5,7 @@ import android.content.Context;
5
5
  import android.content.Intent;
6
6
  import android.content.IntentFilter;
7
7
  import android.os.Build;
8
+ import androidx.annotation.NonNull;
8
9
 
9
10
  import com.onetrust.otpublishers.headless.Public.DataModel.OTProfileSyncParams;
10
11
  import com.onetrust.otpublishers.headless.Public.Keys.OTBroadcastServiceKeys;
@@ -93,7 +94,21 @@ public class OneTrust extends CordovaPlugin{
93
94
  return true;
94
95
  case "getOTGoogleConsentModeData":
95
96
  getOTGoogleConsentModeData(callbackContext);
96
- return true;
97
+ return true;
98
+ case "fetchBannerCmpApiData":
99
+ fetchBannerCmpApiData(callbackContext);
100
+ return true;
101
+ case "fetchPreferencesCmpApiData":
102
+ fetchPreferencesCmpApiData(callbackContext);
103
+ return true;
104
+ case "fetchVendorsCmpApiData":
105
+ fetchVendorsCmpApiData(callbackContext);
106
+ return true;
107
+ case "renameProfile":
108
+ String fromIdentifier = args.optString(0, "");
109
+ String toIdentifier = args.getString(1);
110
+ renameProfile(fromIdentifier, toIdentifier, callbackContext);
111
+ return true;
97
112
  default:
98
113
  callbackContext.error("Unimplemented method called");
99
114
  break;
@@ -393,4 +408,84 @@ public class OneTrust extends CordovaPlugin{
393
408
  };
394
409
  runInThreadPool(runnable);
395
410
  }
411
+
412
+ private void fetchBannerCmpApiData(CallbackContext callbackContext) {
413
+ Runnable runnable = new Runnable() {
414
+ @Override
415
+ public void run() {
416
+ new OTPublishersHeadlessSDK(cordova.getContext()).fetchBannerCmpApiData(new OTCallback() {
417
+ @Override
418
+ public void onSuccess(@NonNull OTResponse otSuccessResponse) {
419
+ callbackContext.success(otSuccessResponse.getResponseData());
420
+ }
421
+
422
+ @Override
423
+ public void onFailure(@NonNull OTResponse otErrorResponse) {
424
+ callbackContext.error(otErrorResponse.getResponseMessage());
425
+ }
426
+ });
427
+ }
428
+ };
429
+ runInThreadPool(runnable);
430
+ }
431
+
432
+ private void fetchPreferencesCmpApiData(CallbackContext callbackContext) {
433
+ Runnable runnable = new Runnable() {
434
+ @Override
435
+ public void run() {
436
+ new OTPublishersHeadlessSDK(cordova.getContext()).fetchPreferencesCmpApiData(new OTCallback() {
437
+ @Override
438
+ public void onSuccess(@NonNull OTResponse otSuccessResponse) {
439
+ callbackContext.success(otSuccessResponse.getResponseData());
440
+ }
441
+
442
+ @Override
443
+ public void onFailure(@NonNull OTResponse otErrorResponse) {
444
+ callbackContext.error(otErrorResponse.getResponseMessage());
445
+ }
446
+ });
447
+ }
448
+ };
449
+ runInThreadPool(runnable);
450
+ }
451
+
452
+ private void fetchVendorsCmpApiData(CallbackContext callbackContext) {
453
+ Runnable runnable = new Runnable() {
454
+ @Override
455
+ public void run() {
456
+ new OTPublishersHeadlessSDK(cordova.getContext()).fetchVendorsCmpApiData(new OTCallback() {
457
+ @Override
458
+ public void onSuccess(@NonNull OTResponse otSuccessResponse) {
459
+ callbackContext.success(otSuccessResponse.getResponseData());
460
+ }
461
+
462
+ @Override
463
+ public void onFailure(@NonNull OTResponse otErrorResponse) {
464
+ callbackContext.error(otErrorResponse.getResponseMessage());
465
+ }
466
+ });
467
+ }
468
+ };
469
+ runInThreadPool(runnable);
470
+ }
471
+
472
+ private void renameProfile(String fromIdentifier, String toIdentifier, CallbackContext callbackContext) {
473
+ Runnable runnable = new Runnable() {
474
+ @Override
475
+ public void run() {
476
+ ot.renameProfile(fromIdentifier, toIdentifier, new OTCallback() {
477
+ @Override
478
+ public void onSuccess(@NonNull OTResponse otResponse) {
479
+ callbackContext.success(1);
480
+ }
481
+
482
+ @Override
483
+ public void onFailure(@NonNull OTResponse otResponse) {
484
+ callbackContext.error(otResponse.getResponseMessage());
485
+ }
486
+ });
487
+ }
488
+ };
489
+ runInThreadPool(runnable);
490
+ }
396
491
  }
@@ -287,7 +287,72 @@ import AppTrackingTransparency
287
287
  self.commandDelegate!.send(pluginResult, callbackId: command.callbackId)
288
288
  }
289
289
  }
290
-
290
+
291
+ // Add this private helper method
292
+ private func fetchCmpApiData(
293
+ fetcher: (@escaping ([String: Any]?) -> Void) -> Void,
294
+ command: CDVInvokedUrlCommand,
295
+ errorMessage: String
296
+ ) {
297
+ fetcher { response in
298
+ let pluginResult: CDVPluginResult
299
+ if let data = response,
300
+ let jsonData = try? JSONSerialization.data(withJSONObject: data),
301
+ let jsonString = String(data: jsonData, encoding: .utf8) {
302
+ pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: jsonString)
303
+ } else {
304
+ pluginResult = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAs: errorMessage)
305
+ }
306
+ self.returnToCordova(pluginResult: pluginResult, command: command)
307
+ }
308
+ }
309
+
310
+ @objc(fetchBannerCmpApiData:)
311
+ func fetchBannerCmpApiData(_ command: CDVInvokedUrlCommand) {
312
+ fetchCmpApiData(
313
+ fetcher: OTPublishersHeadlessSDK.shared.fetchBannerCmpApiData,
314
+ command: command,
315
+ errorMessage: "No response from fetchBannerCmpApiData"
316
+ )
317
+ }
318
+
319
+ @objc(fetchPreferencesCmpApiData:)
320
+ func fetchPreferencesCmpApiData(_ command: CDVInvokedUrlCommand) {
321
+ fetchCmpApiData(
322
+ fetcher: OTPublishersHeadlessSDK.shared.fetchPreferencesCmpApiData,
323
+ command: command,
324
+ errorMessage: "No response from fetchPreferencesCmpApiData"
325
+ )
326
+ }
327
+
328
+ @objc(fetchVendorsCmpApiData:)
329
+ func fetchVendorsCmpApiData(_ command: CDVInvokedUrlCommand) {
330
+ fetchCmpApiData(
331
+ fetcher: OTPublishersHeadlessSDK.shared.fetchVendorsCmpApiData,
332
+ command: command,
333
+ errorMessage: "No response from fetchVendorsCmpApiData"
334
+ )
335
+ }
336
+
337
+ @objc(renameProfile:)
338
+ func renameProfile(_ command: CDVInvokedUrlCommand) {
339
+ let fromIdentifier = command.argument(at: 0) as? String
340
+ guard let toIdentifier = command.argument(at: 1) as? String else {
341
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAs: "toIdentifier is required")
342
+ self.returnToCordova(pluginResult: pluginResult, command: command)
343
+ return
344
+ }
345
+
346
+ OTPublishersHeadlessSDK.shared.renameProfile(from: fromIdentifier, to: toIdentifier) { success in
347
+ let pluginResult: CDVPluginResult
348
+ if success {
349
+ pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: true)
350
+ } else {
351
+ pluginResult = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAs: "Error renaming profile")
352
+ }
353
+ self.returnToCordova(pluginResult: pluginResult, command: command)
354
+ }
355
+ }
291
356
  }
292
357
 
293
358
  extension OneTrust:OTEventListener{
package/www/OneTrust.js CHANGED
@@ -59,6 +59,22 @@ var exports = {
59
59
  exec(success,error, pluginName, 'getOTGoogleConsentModeData')
60
60
  },
61
61
 
62
+ fetchBannerCmpApiData: (success, error) => {
63
+ exec(success, error, pluginName, 'fetchBannerCmpApiData')
64
+ },
65
+
66
+ fetchPreferencesCmpApiData: (success, error) => {
67
+ exec(success, error, pluginName, 'fetchPreferencesCmpApiData')
68
+ },
69
+
70
+ fetchVendorsCmpApiData: (success, error) => {
71
+ exec(success, error, pluginName, 'fetchVendorsCmpApiData')
72
+ },
73
+
74
+ renameProfile: (fromIdentifier, toIdentifier, success, error) => {
75
+ exec(success, error, pluginName, 'renameProfile', [fromIdentifier, toIdentifier])
76
+ },
77
+
62
78
  devicePermission: Object.freeze({idfa:0})
63
79
  }
64
80