@blueconic/blueconic-react-native 2.0.0 → 3.0.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.
Files changed (27) hide show
  1. package/BlueConicReactNative.podspec +23 -23
  2. package/CHANGELOG.md +99 -88
  3. package/LICENSE +3 -3
  4. package/README.md +484 -484
  5. package/android/build.gradle +40 -38
  6. package/android/gradle.properties +9 -0
  7. package/android/src/main/AndroidManifest.xml +4 -5
  8. package/android/src/main/java/com/blueconic/{blueconicreactnative → reactnative}/BlueConicClientModule.java +918 -870
  9. package/android/src/main/java/com/blueconic/{blueconicreactnative → reactnative}/BlueConicClientModuleHelper.java +17 -17
  10. package/android/src/main/java/com/blueconic/{blueconicreactnative → reactnative}/BlueConicClientPackage.java +29 -29
  11. package/android/src/main/java/com/blueconic/{blueconicreactnative → reactnative}/BlueConicInteraction.java +67 -68
  12. package/index.js +6 -6
  13. package/ios/BlueConicClient-Bridging-Header.h +6 -6
  14. package/ios/BlueConicClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -7
  15. package/ios/BlueConicClient.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -8
  16. package/ios/BlueConicClientModule.m +79 -74
  17. package/ios/BlueConicClientModule.swift +545 -516
  18. package/ios/BlueConicInteraction.swift +63 -63
  19. package/package.json +35 -18
  20. package/.gitattributes +0 -1
  21. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  22. package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
  23. package/android/gradlew +0 -172
  24. package/android/gradlew.bat +0 -84
  25. package/android/local.properties +0 -8
  26. package/ios/BlueConicClient.xcodeproj/project.xcworkspace/xcuserdata/youri.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  27. package/ios/BlueConicClient.xcodeproj/xcuserdata/youri.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
@@ -1,871 +1,919 @@
1
-
2
- package com.blueconic.blueconicreactnative;
3
-
4
- import android.app.Activity;
5
- import android.app.Application;
6
- import android.util.Log;
7
-
8
- import com.facebook.react.bridge.ReactApplicationContext;
9
-
10
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
11
- import com.facebook.react.bridge.ReactMethod;
12
- import com.facebook.react.bridge.ReadableArray;
13
- import com.facebook.react.bridge.Callback;
14
- import com.facebook.react.bridge.Promise;
15
- import com.facebook.react.bridge.Arguments;
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.WritableNativeArray;
20
- import com.facebook.react.bridge.WritableNativeMap;
21
- import com.facebook.react.modules.core.DeviceEventManagerModule;
22
-
23
- import java.util.Map;
24
- import java.util.HashMap;
25
- import java.util.Collections;
26
- import java.util.Collection;
27
- import java.util.List;
28
- import java.util.ArrayList;
29
-
30
- import javax.annotation.Nonnull;
31
-
32
- import com.blueconic.BlueConicClient;
33
- import com.blueconic.BlueConicClientFactory;
34
- import com.blueconic.plugin.events.BlueConicEventFactory;
35
- import com.blueconic.plugin.events.BlueConicEventManager;
36
- import com.blueconic.plugin.events.ClickEvent;
37
- import com.blueconic.plugin.events.UpdateValuesEvent;
38
- import com.blueconic.plugin.events.AdvancedEvent;
39
-
40
- public class BlueConicClientModule extends ReactContextBaseJavaModule {
41
- private static BlueConicClientModuleHelper helper;
42
- private ReactApplicationContext reactContext;
43
-
44
- /**
45
- * The constructor calls the constructor of the superclass and creates an instance of
46
- * the BlueConicClientModuleHelper class which is referred to by a static instance variable. This helper stores the
47
- * reactContext, making it available for use by the static publishReceivedParametersEvent method.
48
- * @param reactContext The application context.
49
- */
50
- public BlueConicClientModule(ReactApplicationContext reactContext) {
51
- super(reactContext);
52
- this.reactContext = reactContext;
53
- helper = new BlueConicClientModuleHelper(reactContext);
54
- getBlueConicClientInstance().registerPluginClass(BlueConicInteraction.class, "BlueConicClient.BlueConicInteraction");
55
-
56
- }
57
-
58
- /**
59
- * The superclass ReactContextBaseJavaModule requires that the getName method is implemented.
60
- * The purpose of this method is to return the name of the Native Module which represents this class in JavaScript.
61
- * Hence, this method allows us to access the native module through NativeModules.BlueConic in JavaScript.
62
- * @return String representing the name of this module.
63
- */
64
- @Override
65
- public String getName() {
66
- return "BlueConicClient";
67
- }
68
-
69
-
70
- // MARK: GETTERS
71
- /**
72
- * Gets the ID of the BlueConic profile. The value is passed to the provided promiseas a String.
73
- * @param promise The promise to handle the obtained value. Promises are necessary in Native Modules
74
- * to pass values back to the JavaScript.
75
- */
76
- @ReactMethod
77
- public void getProfileId(@Nonnull Promise promise) {
78
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
79
- String profileId = "";
80
- if (blueConicClient != null) {
81
- profileId = blueConicClient.getProfileId();
82
- }
83
-
84
- promise.resolve(profileId);
85
- }
86
-
87
- /**
88
- * Gets the values of the specified profile property. The values are passed to the provided promise
89
- * as separate Strings.
90
- * @param property The profile property for which to get the values.
91
- * @param promise The Promise to handle the obtained values. Promises are necessary in Native Modules
92
- * to pass values back to the JavaScript.
93
- */
94
- @ReactMethod
95
- public void getProfileValue(@Nonnull String property, @Nonnull Promise promise) {
96
- final List<String> result = new ArrayList<String>();
97
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
98
-
99
- if (blueConicClient != null) {
100
- result.add(blueConicClient.getProfileValue(property));
101
- }
102
-
103
- promise.resolve(result);
104
- }
105
-
106
- /**
107
- * Gets the values of the specified profile property. The values are passed to the provided promise
108
- * as separate Strings.
109
- * @param property The profile property for which to get the values.
110
- * @param promise The Promise to handle the obtained values. Promises are necessary in Native Modules
111
- * to pass values back to the JavaScript.
112
- */
113
- @ReactMethod
114
- public void getProfileValues(@Nonnull String property, @Nonnull Promise promise) {
115
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
116
-
117
- if (blueConicClient != null) {
118
- Collection<String> values = blueConicClient.getProfileValues(property);
119
- promise.resolve(Arguments.fromList(new ArrayList<String>(values)));
120
- } else {
121
- promise.resolve(Arguments.createArray());
122
- }
123
- }
124
-
125
- /**
126
- * Gets the ID of the BlueConic profile. The value is passed to the provided callback function as a String.
127
- * @param callback The Callback function to handle the obtained value. Callbacks are necessary in Native Modules
128
- * to pass values back to the JavaScript.
129
- */
130
- @ReactMethod
131
- public void getProfileIdWithCallback(@Nonnull Callback callback) {
132
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
133
- String profileId = "";
134
- if (blueConicClient != null) {
135
- profileId = blueConicClient.getProfileId();
136
- }
137
-
138
- callback.invoke(profileId);
139
- }
140
-
141
- /**
142
- * Gets the values of the specified profile property. The values are passed to the provided callback function
143
- * as separate Strings.
144
- * @param property The profile property for which to get the values.
145
- * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
146
- * to pass values back to the JavaScript.
147
- */
148
- @ReactMethod
149
- public void getProfileValueWithCallback(@Nonnull String property, @Nonnull Callback callback) {
150
- final List<String> result = new ArrayList<String>();
151
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
152
-
153
- if (blueConicClient != null) {
154
- result.add(blueConicClient.getProfileValue(property));
155
- }
156
-
157
- callback.invoke(result);
158
- }
159
-
160
- /**
161
- * Gets the values of the specified profile property. The values are passed to the provided callback function
162
- * as separate Strings.
163
- * @param property The profile property for which to get the values.
164
- * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
165
- * to pass values back to the JavaScript.
166
- */
167
- @ReactMethod
168
- public void getProfileValuesWithCallback(@Nonnull String property, @Nonnull Callback callback) {
169
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
170
-
171
- if (blueConicClient != null) {
172
- Collection<String> values = blueConicClient.getProfileValues(property);
173
- callback.invoke(values.toArray());
174
- } else {
175
- callback.invoke(new ArrayList<String>());
176
- }
177
- }
178
-
179
- /**
180
- * Gets the privacy legislation. The values are passed to the provided promise
181
- * as separate String.
182
- * @param promise The Promise to handle the obtained values. Promises are necessary in Native Modules
183
- * to pass values back to the JavaScript.
184
- */
185
- @ReactMethod
186
- public void getPrivacyLegislation(@Nonnull Promise promise) {
187
- final List<String> result = new ArrayList<String>();
188
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
189
-
190
- if (blueConicClient != null) {
191
- result.add(blueConicClient.getPrivacyLegislation());
192
- }
193
-
194
- promise.resolve(result);
195
- }
196
-
197
- /**
198
- * Gets the privacy legislation. The values are passed to the provided callback function
199
- * as separate String.
200
- * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
201
- * to pass values back to the JavaScript.
202
- */
203
- @ReactMethod
204
- public void getPrivacyLegislationWithCallback(@Nonnull Callback callback) {
205
- final List<String> result = new ArrayList<String>();
206
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
207
-
208
- if (blueConicClient != null) {
209
- result.add(blueConicClient.getPrivacyLegislation());
210
- }
211
-
212
- callback.invoke(result);
213
- }
214
-
215
- /**
216
- * Gets the consented objectives. The values are passed to the provided promise
217
- * as separate Strings.
218
- * @param promise The Promise to handle the obtained values. Promises are necessary in Native Modules
219
- * to pass values back to the JavaScript.
220
- */
221
- @ReactMethod
222
- public void getConsentedObjectives(@Nonnull Promise promise) {
223
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
224
-
225
- if (blueConicClient != null) {
226
- Collection<String> values = blueConicClient.getConsentedObjectives();
227
- promise.resolve(Arguments.fromList(new ArrayList<String>(values)));
228
- } else {
229
- promise.resolve(Arguments.createArray());
230
- }
231
- }
232
-
233
- /**
234
- * Gets the consented objectives. The values are passed to the provided callback function
235
- * as separate Strings.
236
- * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
237
- * to pass values back to the JavaScript.
238
- */
239
- @ReactMethod
240
- public void getConsentedObjectivesWithCallback(@Nonnull Callback callback) {
241
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
242
-
243
- if (blueConicClient != null) {
244
- Collection<String> values = blueConicClient.getConsentedObjectives();
245
- callback.invoke(values.toArray());
246
- } else {
247
- callback.invoke(new ArrayList<String>());
248
- }
249
- }
250
-
251
- /**
252
- * Gets the refused objectives. The values are passed to the provided promise
253
- * as separate Strings.
254
- * @param promise The Promise to handle the obtained values. Promises are necessary in Native Modules
255
- * to pass values back to the JavaScript.
256
- */
257
- @ReactMethod
258
- public void getRefusedObjectives(@Nonnull Promise promise) {
259
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
260
-
261
- if (blueConicClient != null) {
262
- Collection<String> values = blueConicClient.getRefusedObjectives();
263
- promise.resolve(Arguments.fromList(new ArrayList<String>(values)));
264
- } else {
265
- promise.resolve(Arguments.createArray());
266
- }
267
- }
268
-
269
- /**
270
- * Gets the refused objectives. The values are passed to the provided callback function
271
- * as separate Strings.
272
- * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
273
- * to pass values back to the JavaScript.
274
- */
275
- @ReactMethod
276
- public void getRefusedObjectivesWithCallback(@Nonnull Callback callback) {
277
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
278
-
279
- if (blueConicClient != null) {
280
- Collection<String> values = blueConicClient.getRefusedObjectives();
281
- callback.invoke(values.toArray());
282
- } else {
283
- callback.invoke(new ArrayList<String>());
284
- }
285
- }
286
-
287
-
288
- /**
289
- * Gets the segments of the profile.
290
- * To retrieve and update the Segments you have to register a pageview first.
291
- * The values are passed to the provided promise
292
- * as a list of Objects containing id and name.
293
- * @param promise The Promise to handle the obtained values. Promises are necessary in Native Modules
294
- * to pass values back to the JavaScript.
295
- */
296
- @ReactMethod
297
- public void getSegments(@Nonnull Promise promise) {
298
- promise.resolve(getFormattedSegments());
299
- }
300
-
301
- /**
302
- * Gets the segments of the profile.
303
- * To retrieve and update the Segments you have to register a pageview first.
304
- * The values are passed to the provided promise
305
- * as a list of Objects containing id and name.
306
- * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
307
- * to pass values back to the JavaScript.
308
- */
309
- @ReactMethod
310
- public void getSegmentsWithCallback(@Nonnull Callback callback) {
311
- callback.invoke(getFormattedSegments());
312
- }
313
-
314
- // MARK: ADDERS
315
- /**
316
- * Adds the given values to the specified profile property.
317
- * @param property The profile property to which to add the values.
318
- * @param values A ReadableArray containing Strings that will be added to the profile property.
319
- */
320
- @ReactMethod
321
- public void addProfileValues(@Nonnull String property, @Nonnull ReadableArray values) {
322
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
323
- if (blueConicClient != null) {
324
- blueConicClient.addProfileValues(property, Arguments.toList(values));
325
- }
326
- }
327
-
328
- /**
329
- * Adds the given values to the specified profile property.
330
- * @param property The profile property to which to add the values.
331
- * @param value A ReadableArray containing Strings that will be added to the profile property.
332
- */
333
- @ReactMethod
334
- public void addProfileValue(@Nonnull String property, @Nonnull String value) {
335
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
336
- if (blueConicClient != null) {
337
- blueConicClient.addProfileValue(property, value);
338
- }
339
- }
340
-
341
- /**
342
- * Adds an objective to the consented objectives list.
343
- * @param objectiveId The id of the objective to add to consented objectives.
344
- */
345
- @ReactMethod
346
- public void addConsentedObjective(@Nonnull String objectiveId) {
347
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
348
- if (blueConicClient != null) {
349
- blueConicClient.addConsentedObjective(objectiveId);
350
- }
351
- }
352
-
353
- /**
354
- * Adds an objective to the refused objectives list.
355
- * @param objectiveId The id of the objective to add to refused objectives.
356
- */
357
- @ReactMethod
358
- public void addRefusedObjective(@Nonnull String objectiveId) {
359
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
360
- if (blueConicClient != null) {
361
- blueConicClient.addRefusedObjective(objectiveId);
362
- }
363
- }
364
-
365
- // MARK: SETTERS
366
- /**
367
- * Sets the given values for the specified profile property.
368
- * @param property The profile property for which to set the values.
369
- * @param values A ReadableArray containing Strings that will be set as the new values for the profile property.
370
- */
371
- @ReactMethod
372
- public void setProfileValues(@Nonnull String property, @Nonnull ReadableArray values) {
373
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
374
- if (blueConicClient != null) {
375
- blueConicClient.setProfileValues(property, Arguments.toList(values));
376
- }
377
- }
378
-
379
- /**
380
- * Set the given value for the specified profile property.
381
- * @param property The profile property for which to set the values.
382
- * @param value A ReadableArray containing Strings that will be set as the new values for the profile property.
383
- */
384
- @ReactMethod
385
- public void setProfileValue(@Nonnull String property, @Nonnull String value) {
386
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
387
- if (blueConicClient != null) {
388
- blueConicClient.setProfileValue(property, value);
389
- }
390
- }
391
-
392
- /**
393
- * Increments the given values to the specified profile property.
394
- * @param property The profile property to which to increment the values.
395
- * @param value A ReadableArray containing Strings that will be incremented to the profile property.
396
- */
397
- @ReactMethod
398
- public void incrementProfileValue(@Nonnull String property, @Nonnull String value) {
399
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
400
- if (blueConicClient != null) {
401
- blueConicClient.incrementProfileValue(property, value);
402
- }
403
- }
404
-
405
- /**
406
- * Set the privacy legislation.
407
- * @param privacyLegislation The privacy legislation.
408
- */
409
- @ReactMethod
410
- public void setPrivacyLegislation(@Nonnull String privacyLegislation) {
411
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
412
- if (blueConicClient != null) {
413
- blueConicClient.setPrivacyLegislation(privacyLegislation);
414
- }
415
- }
416
-
417
- /**
418
- * Sets the given objectives for consented objectives.
419
- * @param objectiveIds A ReadableArray containing IDs of Objectives that will be set as the new values for Consented objectives.
420
- */
421
- @ReactMethod
422
- public void setConsentedObjectives(@Nonnull ReadableArray objectiveIds) {
423
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
424
- if (blueConicClient != null) {
425
- blueConicClient.setConsentedObjectives(Arguments.toList(objectiveIds));
426
- }
427
- }
428
-
429
- /**
430
- * Sets the given objectives for consented objectives.
431
- * @param objectiveIds A ReadableArray containing IDs of Objectives that will be set as the new values for Consented objectives.
432
- */
433
- @ReactMethod
434
- public void setRefusedObjectives(@Nonnull ReadableArray objectiveIds) {
435
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
436
- if (blueConicClient != null) {
437
- blueConicClient.setRefusedObjectives(Arguments.toList(objectiveIds));
438
- }
439
- }
440
-
441
- /**
442
- * Set enabled.
443
- * Define to enable and disable the BlueConicClient
444
- * To prevent or re-activate tracking data
445
- * @param isEnabled to enable or disable the BlueConicClient.
446
- */
447
- @ReactMethod
448
- public void setEnabled(@Nonnull Boolean isEnabled) {
449
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
450
- if (blueConicClient != null) {
451
- blueConicClient.setEnabled(isEnabled == null ? false : isEnabled.booleanValue());
452
- }
453
-
454
- }
455
-
456
- /**
457
- * Return is BlueConicClient enabled. The value is passed to the provided callback function as seperated Strings.
458
- * @param promise The promise to handle the obtained value. Promises are necessary in Native Modules
459
- * Native Modules to pass values back to the JavaScript.
460
- */
461
- @ReactMethod
462
- public void isEnabled(@Nonnull Promise promise) {
463
- final List<Boolean> result = new ArrayList<Boolean>();
464
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
465
-
466
- if (blueConicClient != null) {
467
- result.add(Boolean.valueOf(blueConicClient.isEnabled()));
468
- }
469
-
470
- promise.resolve(result);
471
- }
472
-
473
- /**
474
- * Return is BlueConicClient enabled. The value is passed to the provided callback function as seperated Strings
475
- * @param callback: The callback function to handle the obtained value. Callbacks are necessary in
476
- * Native Modules to pass values back to the JavaScript.
477
- */
478
- @ReactMethod
479
- public void isEnabledWithCallback(@Nonnull Callback callback) {
480
- final List<Boolean> result = new ArrayList<Boolean>();
481
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
482
-
483
- if (blueConicClient != null) {
484
- result.add(Boolean.valueOf(blueConicClient.isEnabled()));
485
- }
486
-
487
- callback.invoke(result);
488
- }
489
-
490
- /**
491
- * Return whether the BlueConic profile is part of the BlueConic segment. The value is passed to the provided callback function as Boolean.
492
- * @param segmentId The id of the segment
493
- * @param promise The promise to handle the obtained value. Promises are necessary in Native Modules
494
- * Native Modules to pass values back to the JavaScript.
495
- */
496
- @ReactMethod
497
- public void hasSegment(@Nonnull String segmentId, @Nonnull Promise promise) {
498
- final List<Boolean> result = new ArrayList<Boolean>();
499
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
500
-
501
- if (blueConicClient != null) {
502
- result.add(Boolean.valueOf(blueConicClient.hasSegment(segmentId)));
503
- }
504
-
505
- promise.resolve(result);
506
- }
507
-
508
- /**
509
- * Return whether the BlueConic profile is part of the BlueConic segment. The value is passed to the provided callback function as Boolean.
510
- * @param segmentId The id of the segment
511
- * @param callback: The callback function to handle the obtained value. Callbacks are necessary in
512
- * Native Modules to pass values back to the JavaScript.
513
- */
514
- @ReactMethod
515
- public void hasSegmentWithCallback(@Nonnull String segmentId, @Nonnull Callback callback) {
516
- final List<Boolean> result = new ArrayList<Boolean>();
517
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
518
-
519
- if (blueConicClient != null) {
520
- result.add(Boolean.valueOf(blueConicClient.hasSegment(segmentId)));
521
- }
522
-
523
- callback.invoke(result);
524
- }
525
-
526
- // MARK: REGISTERS
527
- /**
528
- * Create Event.
529
- * @param eventName The name of the event
530
- * @param readableMap The readable map retrieved from React native
531
- */
532
- @ReactMethod
533
- public void createEvent(@Nonnull String eventName, ReadableMap readableMap) {
534
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
535
- final Map<String, Object> properties = readableMap.toHashMap();
536
-
537
- if (blueConicClient != null) {
538
- blueConicClient.createEventWithData(eventName, properties);
539
- }
540
- }
541
-
542
- /**
543
- * Create Event.
544
- * @param eventName The name of the event
545
- * @param readableMap The readable map retrieved from React native
546
- * @param promise The promise to handle the obtained value. Promises are necessary in Native Modules
547
- * Native Modules to pass values back to the JavaScript.
548
- */
549
- @ReactMethod
550
- public void createEventSync(@Nonnull String eventName, ReadableMap readableMap, @Nonnull final Promise promise) {
551
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
552
- final Map<String, Object> properties = readableMap.toHashMap();
553
-
554
- if (blueConicClient != null) {
555
- blueConicClient.createEventWithData(eventName, properties, new Runnable() {
556
- @Override
557
- public void run() {
558
- promise.resolve(Arguments.createArray());
559
- }
560
- });
561
- return;
562
- }
563
-
564
- promise.resolve(Arguments.createArray());
565
- }
566
-
567
- /**
568
- * Create Event.
569
- * @param eventName The name of the event
570
- * @param readableMap The readable map retrieved from React native
571
- * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
572
- * to pass values back to the JavaScript.
573
- */
574
- @ReactMethod
575
- public void createEventSyncWithCallback(@Nonnull String eventName, ReadableMap readableMap, @Nonnull final Callback callback) {
576
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
577
- final Map<String, Object> properties = readableMap.toHashMap();
578
-
579
- if (blueConicClient != null) {
580
- blueConicClient.createEventWithData(eventName, properties, new Runnable() {
581
- @Override
582
- public void run() {
583
- callback.invoke(Arguments.createArray());
584
- }
585
- });
586
- return;
587
- }
588
-
589
- callback.invoke(Arguments.createArray());
590
- }
591
-
592
-
593
- /**
594
- * Update sync the BlueConic Profile
595
- */
596
- @ReactMethod
597
- public void updateProfile() {
598
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
599
-
600
- if (blueConicClient != null) {
601
- blueConicClient.updateProfile();
602
- }
603
- }
604
-
605
- /**
606
- * Update sync the BlueConic Profile
607
- * @param promise The promise to handle the obtained value. Promises are necessary in Native Modules
608
- * Native Modules to pass values back to the JavaScript.
609
- */
610
- @ReactMethod
611
- public void updateProfileSync(@Nonnull final Promise promise) {
612
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
613
-
614
- if (blueConicClient != null) {
615
- blueConicClient.updateProfile(new Runnable() {
616
- @Override
617
- public void run() {
618
- promise.resolve(Arguments.createArray());
619
- }
620
- });
621
-
622
- return;
623
- }
624
-
625
- promise.resolve(Arguments.createArray());
626
- }
627
-
628
- /**
629
- * Update sync the BlueConic Profile
630
- * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
631
- * to pass values back to the JavaScript.
632
- */
633
- @ReactMethod
634
- public void updateProfileSyncWithCallback(@Nonnull final Callback callback) {
635
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
636
-
637
- if (blueConicClient != null) {
638
- blueConicClient.updateProfile(new Runnable() {
639
- @Override
640
- public void run() {
641
- callback.invoke(Arguments.createArray());
642
- }
643
- });
644
-
645
- return;
646
- }
647
-
648
- callback.invoke(Arguments.createArray());
649
- }
650
-
651
- /**
652
- * Calls the createEvent method of the BlueConicClient to register a PAGEVIEW event. This must be called on every
653
- * screen change as it triggers the BlueConic SDK to load all plugins (i.e. listeners, dialogues) for the screen.
654
- * @param screenName The name of the screen.
655
- */
656
- @ReactMethod
657
- public void registerPageView(@Nonnull String screenName) {
658
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
659
- if (blueConicClient != null) {
660
- // blueConicClient instance must have an activity or application
661
- final Map<String, String> properties = new HashMap<>();
662
- properties.put("screenName", screenName);
663
- Activity activity = getCurrentActivity();
664
- if (activity == null) {
665
- activity = new Activity();
666
- }
667
-
668
- blueConicClient.createEvent("PAGEVIEW", properties, activity);
669
- } else {
670
- Log.e("BlueConic", "Unable to register a PAGEVIEW-event: Activity not available.");
671
- }
672
- }
673
-
674
- /**
675
- * Calls the createEvent method of the BlueConicClient to register a PAGEVIEW event. This must be called on every
676
- * screen change as it triggers the BlueConic SDK to load all plugins (i.e. listeners, dialogues) for the screen.
677
- * @param screenName The name of the screen.
678
- */
679
- @ReactMethod
680
- public void registerPageViewSync(@Nonnull String screenName, @Nonnull final Promise promise) {
681
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
682
- if (blueConicClient != null) {
683
- // blueConicClient instance must have an activity or application
684
- final Map<String, String> properties = new HashMap<>();
685
- properties.put("screenName", screenName);
686
- Activity activity = getCurrentActivity();
687
- if (activity == null) {
688
- activity = new Activity();
689
- }
690
-
691
- blueConicClient.createEvent("PAGEVIEW", properties, activity, new Runnable() {
692
- @Override
693
- public void run() {
694
- promise.resolve(Arguments.createArray());
695
- }
696
- });
697
- } else {
698
- Log.e("BlueConic", "Unable to register a PAGEVIEW-event: Activity not available.");
699
- promise.resolve(Arguments.createArray());
700
- }
701
- }
702
-
703
- /**
704
- * Calls the createEvent method of the BlueConicClient to register a PAGEVIEW event. This must be called on every
705
- * screen change as it triggers the BlueConic SDK to load all plugins (i.e. listeners, dialogues) for the screen.
706
- * @param screenName The name of the screen.
707
- */
708
- @ReactMethod
709
- public void registerPageViewSyncCallback(@Nonnull String screenName, @Nonnull final Callback callback) {
710
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
711
- if (blueConicClient != null) {
712
- // blueConicClient instance must have an activity or application
713
- final Map<String, String> properties = new HashMap<>();
714
- properties.put("screenName", screenName);
715
- Activity activity = getCurrentActivity();
716
- if (activity == null) {
717
- activity = new Activity();
718
- }
719
-
720
- blueConicClient.createEvent("PAGEVIEW", properties, activity, new Runnable() {
721
- @Override
722
- public void run() {
723
- callback.invoke(Arguments.createArray());
724
- }
725
- });
726
- } else {
727
- Log.e("BlueConic", "Unable to register a PAGEVIEW-event: Activity not available.");
728
- callback.invoke(Arguments.createArray());
729
- }
730
- }
731
-
732
- /**
733
- * Creates a ClickEvent for the given selector and publishes the event to BlueConic using the EventManager.
734
- * @param selector The selector to identify the clicked component.
735
- */
736
- @ReactMethod
737
- public void registerClickEvent(@Nonnull String selector) {
738
- getBlueConicEventManagerInstance().publish(new ClickEvent(selector));
739
- }
740
-
741
- /**
742
- * Creates a ClickEvent for the given selector and values, and publishes the event using the EventManager.
743
- * @param selector The selector to identify the clicked component.
744
- * @param values The values to pass to BlueConic as context of the event.
745
- */
746
- @ReactMethod
747
- public void registerClickEventWithContext(@Nonnull String selector, @Nonnull ReadableArray values) {
748
- getBlueConicEventManagerInstance().publish(new ClickEvent(selector, Arguments.toList(values)));
749
- }
750
-
751
- /**
752
- * Creates an UpdateValuesEvent for the given selector and value, and publishes the event using the EventManager.
753
- * @param selector The selector to identify the component with updated values.
754
- * @param value The value to be passed on to BlueConic.
755
- */
756
- @ReactMethod
757
- public void registerUpdateValuesEvent(@Nonnull String selector, @Nonnull String value) {
758
- UpdateValuesEvent event = new UpdateValuesEvent(selector, Collections.singletonList(value));
759
- getBlueConicEventManagerInstance().publish(event);
760
- }
761
-
762
- /**
763
- * Creates an AdvancedEvent with the given name and values, and publishes the event using the EventManager.
764
- * @param name The name to identify the event.
765
- * @param values The values to pass to BlueConic as context of the event.
766
- */
767
- @ReactMethod
768
- public void registerAdvancedEvent(@Nonnull String name, @Nonnull ReadableArray values) {
769
- AdvancedEvent event = new AdvancedEvent(name, Arguments.toList(values));
770
- getBlueConicEventManagerInstance().publish(event);
771
- }
772
-
773
-
774
-
775
- /**
776
- * Destroys all active BlueConic plugins (i.e. instances of listeners and dialogues). This method must be called
777
- * in the onPause of an activity if the app targets Android API versions before API 14. It should also be called if
778
- * one switches screens in the app without calling the onPause of the previous Activity.
779
- *
780
- */
781
- @ReactMethod
782
- public void destroyPlugins() {
783
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
784
- if (blueConicClient != null) {
785
- blueConicClient.destroyPlugins();
786
- }
787
- }
788
-
789
- /**
790
- * Sends an event to the BlueConic server, indicating that a certain interaction was viewed, clicked, or converted for.
791
- * @param eventType The event type to register for the interaction. Possible events are "VIEW", "CLICK" and "CONVERSION".
792
- * @param interactionId The unique identifier of the interaction.
793
- */
794
- @ReactMethod
795
- public void registerDialogueEvent(@Nonnull String eventType, @Nonnull String interactionId) {
796
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
797
- if (blueConicClient != null) {
798
- final Map<String, String> interactionIdMap = new HashMap<>();
799
- interactionIdMap.put("interactionId", interactionId);
800
- blueConicClient.createEvent(eventType, interactionIdMap);
801
- }
802
- }
803
-
804
-
805
- /**
806
- * Returns an instance of the BlueConicClient
807
- * @return BlueConicClient
808
- */
809
- private BlueConicClient getBlueConicClientInstance() {
810
- // Retrieve current Activity from ReactContextBaseJavaModule
811
- final Activity currentActivity = getCurrentActivity();
812
- if (currentActivity != null) {
813
- // Activity found and return a BlueConicClient instance
814
- return BlueConicClientFactory.getInstance(currentActivity);
815
- }
816
-
817
- // Current Activity is not set yet, try using BaseContext as a safe-cast to Application
818
- if (this.reactContext.getApplicationContext() instanceof Application) {
819
- // Cast BaseContext to an Application
820
- final Application application = (Application) this.reactContext.getApplicationContext();
821
- return BlueConicClientFactory.getInstance(application);
822
- }
823
-
824
- return null;
825
- }
826
-
827
- /**
828
- * Returns an instance of the BlueConicEventManager
829
- * @return BlueConicClient
830
- */
831
- private BlueConicEventManager getBlueConicEventManagerInstance() {
832
- return BlueConicEventFactory.getInstance();
833
- }
834
-
835
- private WritableArray getFormattedSegments() {
836
- final WritableArray result = new WritableNativeArray();
837
- final BlueConicClient blueConicClient = getBlueConicClientInstance();
838
-
839
- if (blueConicClient == null) {
840
- return result;
841
- }
842
- final Collection<BlueConicClient.Segment> segments = blueConicClient.getSegments();
843
-
844
- for (BlueConicClient.Segment segment : segments) {
845
- final WritableMap item = new WritableNativeMap();
846
- item.putString("id", segment.getId());
847
- item.putString("name", segment.getName());
848
- result.pushMap(item);
849
- }
850
-
851
- return result;
852
- }
853
-
854
- /**
855
- * Static method that is called by the BlueConicInteraction when it receives the parameters of the dialogue,
856
- * and when the dialogue is destroyed by the BlueConic SDK. An event is published to which the JavaScript of the
857
- * app should subscribe.
858
- * @param properties The properties of the dialogues as received from BlueConic.
859
- * @param eventName The name of the event to be published.
860
- */
861
- static void publishDialogueEvent(@Nonnull Map<String, Object> properties, String eventName) {
862
- WritableMap map = Arguments.makeNativeMap(properties);
863
-
864
- if (helper != null) {
865
- helper
866
- .getReactContext()
867
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
868
- .emit(eventName, map);
869
- }
870
- }
1
+
2
+ package com.blueconic.reactnative;
3
+
4
+ import android.app.Activity;
5
+ import android.os.Handler;
6
+ import android.os.Looper;
7
+ import android.util.Log;
8
+
9
+ import com.blueconic.impl.BlueConicClientImpl;
10
+ import com.facebook.react.bridge.ReactApplicationContext;
11
+
12
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
13
+ import com.facebook.react.bridge.ReactMethod;
14
+ import com.facebook.react.bridge.ReadableArray;
15
+ import com.facebook.react.bridge.Callback;
16
+ import com.facebook.react.bridge.Promise;
17
+ import com.facebook.react.bridge.Arguments;
18
+ import com.facebook.react.bridge.ReadableMap;
19
+ import com.facebook.react.bridge.WritableArray;
20
+ import com.facebook.react.bridge.WritableMap;
21
+ import com.facebook.react.bridge.WritableNativeArray;
22
+ import com.facebook.react.bridge.WritableNativeMap;
23
+ import com.facebook.react.modules.core.DeviceEventManagerModule;
24
+
25
+ import java.util.Map;
26
+ import java.util.HashMap;
27
+ import java.util.Collections;
28
+ import java.util.Collection;
29
+ import java.util.List;
30
+ import java.util.ArrayList;
31
+
32
+ import javax.annotation.Nonnull;
33
+
34
+ import com.blueconic.BlueConicClient;
35
+ import com.blueconic.BlueConicClientFactory;
36
+ import com.blueconic.plugin.events.BlueConicEventFactory;
37
+ import com.blueconic.plugin.events.BlueConicEventManager;
38
+ import com.blueconic.plugin.events.ClickEvent;
39
+ import com.blueconic.plugin.events.UpdateValuesEvent;
40
+ import com.blueconic.plugin.events.FormSubmitEvent;
41
+ import com.blueconic.plugin.events.UpdateContentEvent;
42
+ import com.blueconic.plugin.events.AdvancedEvent;
43
+
44
+ public class BlueConicClientModule extends ReactContextBaseJavaModule {
45
+ private static BlueConicClientModuleHelper helper;
46
+ private ReactApplicationContext reactContext;
47
+
48
+ /**
49
+ * The constructor calls the constructor of the superclass and creates an instance of
50
+ * the BlueConicClientModuleHelper class which is referred to by a static instance variable. This helper stores the
51
+ * reactContext, making it available for use by the static publishReceivedParametersEvent method.
52
+ * @param reactContext The application context.
53
+ */
54
+ public BlueConicClientModule(ReactApplicationContext reactContext) {
55
+ super(reactContext);
56
+ this.reactContext = reactContext;
57
+ helper = new BlueConicClientModuleHelper(reactContext);
58
+
59
+ // Delayed plugin class register due to availability of activity context
60
+ new Handler(Looper.getMainLooper()).postDelayed(() -> {
61
+ BlueConicClient blueConicClient = getBlueConicClientInstance();
62
+ if (blueConicClient != null) {
63
+ blueConicClient.registerPluginClass(BlueConicInteraction.class, "BlueConicClient.BlueConicInteraction");
64
+ }
65
+ }, 2000);
66
+ }
67
+
68
+ /**
69
+ * The superclass ReactContextBaseJavaModule requires that the getName method is implemented.
70
+ * The purpose of this method is to return the name of the Native Module which represents this class in JavaScript.
71
+ * Hence, this method allows us to access the native module through NativeModules.BlueConic in JavaScript.
72
+ * @return String representing the name of this module.
73
+ */
74
+ @Override
75
+ public String getName() {
76
+ return "BlueConicClient";
77
+ }
78
+
79
+
80
+ // MARK: GETTERS
81
+ /**
82
+ * Gets the ID of the BlueConic profile. The value is passed to the provided promiseas a String.
83
+ * @param promise The promise to handle the obtained value. Promises are necessary in Native Modules
84
+ * to pass values back to the JavaScript.
85
+ */
86
+ @ReactMethod
87
+ public void getProfileId(@Nonnull Promise promise) {
88
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
89
+ String profileId = "";
90
+ if (blueConicClient != null) {
91
+ profileId = blueConicClient.getProfileId();
92
+ }
93
+
94
+ promise.resolve(profileId);
95
+ }
96
+
97
+ /**
98
+ * Gets the values of the specified profile property. The values are passed to the provided promise
99
+ * as separate Strings.
100
+ * @param property The profile property for which to get the values.
101
+ * @param promise The Promise to handle the obtained values. Promises are necessary in Native Modules
102
+ * to pass values back to the JavaScript.
103
+ */
104
+ @ReactMethod
105
+ public void getProfileValue(@Nonnull String property, @Nonnull Promise promise) {
106
+ final List<String> result = new ArrayList<String>();
107
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
108
+
109
+ if (blueConicClient != null) {
110
+ result.add(blueConicClient.getProfileValue(property));
111
+ }
112
+
113
+ promise.resolve(result);
114
+ }
115
+
116
+ /**
117
+ * Gets the values of the specified profile property. The values are passed to the provided promise
118
+ * as separate Strings.
119
+ * @param property The profile property for which to get the values.
120
+ * @param promise The Promise to handle the obtained values. Promises are necessary in Native Modules
121
+ * to pass values back to the JavaScript.
122
+ */
123
+ @ReactMethod
124
+ public void getProfileValues(@Nonnull String property, @Nonnull Promise promise) {
125
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
126
+
127
+ if (blueConicClient != null) {
128
+ Collection<String> values = blueConicClient.getProfileValues(property);
129
+ promise.resolve(Arguments.fromList(new ArrayList<String>(values)));
130
+ } else {
131
+ promise.resolve(Arguments.createArray());
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Gets the ID of the BlueConic profile. The value is passed to the provided callback function as a String.
137
+ * @param callback The Callback function to handle the obtained value. Callbacks are necessary in Native Modules
138
+ * to pass values back to the JavaScript.
139
+ */
140
+ @ReactMethod
141
+ public void getProfileIdWithCallback(@Nonnull Callback callback) {
142
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
143
+ String profileId = "";
144
+ if (blueConicClient != null) {
145
+ profileId = blueConicClient.getProfileId();
146
+ }
147
+
148
+ callback.invoke(profileId);
149
+ }
150
+
151
+ /**
152
+ * Gets the values of the specified profile property. The values are passed to the provided callback function
153
+ * as separate Strings.
154
+ * @param property The profile property for which to get the values.
155
+ * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
156
+ * to pass values back to the JavaScript.
157
+ */
158
+ @ReactMethod
159
+ public void getProfileValueWithCallback(@Nonnull String property, @Nonnull Callback callback) {
160
+ final List<String> result = new ArrayList<String>();
161
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
162
+
163
+ if (blueConicClient != null) {
164
+ result.add(blueConicClient.getProfileValue(property));
165
+ }
166
+
167
+ callback.invoke(result);
168
+ }
169
+
170
+ /**
171
+ * Gets the values of the specified profile property. The values are passed to the provided callback function
172
+ * as separate Strings.
173
+ * @param property The profile property for which to get the values.
174
+ * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
175
+ * to pass values back to the JavaScript.
176
+ */
177
+ @ReactMethod
178
+ public void getProfileValuesWithCallback(@Nonnull String property, @Nonnull Callback callback) {
179
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
180
+
181
+ if (blueConicClient != null) {
182
+ Collection<String> values = blueConicClient.getProfileValues(property);
183
+ callback.invoke(values.toArray());
184
+ } else {
185
+ callback.invoke(new ArrayList<String>());
186
+ }
187
+ }
188
+
189
+ /**
190
+ * Gets the privacy legislation. The values are passed to the provided promise
191
+ * as separate String.
192
+ * @param promise The Promise to handle the obtained values. Promises are necessary in Native Modules
193
+ * to pass values back to the JavaScript.
194
+ */
195
+ @ReactMethod
196
+ public void getPrivacyLegislation(@Nonnull Promise promise) {
197
+ final List<String> result = new ArrayList<String>();
198
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
199
+
200
+ if (blueConicClient != null) {
201
+ result.add(blueConicClient.getPrivacyLegislation());
202
+ }
203
+
204
+ promise.resolve(result);
205
+ }
206
+
207
+ /**
208
+ * Gets the privacy legislation. The values are passed to the provided callback function
209
+ * as separate String.
210
+ * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
211
+ * to pass values back to the JavaScript.
212
+ */
213
+ @ReactMethod
214
+ public void getPrivacyLegislationWithCallback(@Nonnull Callback callback) {
215
+ final List<String> result = new ArrayList<String>();
216
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
217
+
218
+ if (blueConicClient != null) {
219
+ result.add(blueConicClient.getPrivacyLegislation());
220
+ }
221
+
222
+ callback.invoke(result);
223
+ }
224
+
225
+ /**
226
+ * Gets the consented objectives. The values are passed to the provided promise
227
+ * as separate Strings.
228
+ * @param promise The Promise to handle the obtained values. Promises are necessary in Native Modules
229
+ * to pass values back to the JavaScript.
230
+ */
231
+ @ReactMethod
232
+ public void getConsentedObjectives(@Nonnull Promise promise) {
233
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
234
+
235
+ if (blueConicClient != null) {
236
+ Collection<String> values = blueConicClient.getConsentedObjectives();
237
+ promise.resolve(Arguments.fromList(new ArrayList<String>(values)));
238
+ } else {
239
+ promise.resolve(Arguments.createArray());
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Gets the consented objectives. The values are passed to the provided callback function
245
+ * as separate Strings.
246
+ * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
247
+ * to pass values back to the JavaScript.
248
+ */
249
+ @ReactMethod
250
+ public void getConsentedObjectivesWithCallback(@Nonnull Callback callback) {
251
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
252
+
253
+ if (blueConicClient != null) {
254
+ Collection<String> values = blueConicClient.getConsentedObjectives();
255
+ callback.invoke(values.toArray());
256
+ } else {
257
+ callback.invoke(new ArrayList<String>());
258
+ }
259
+ }
260
+
261
+ /**
262
+ * Gets the refused objectives. The values are passed to the provided promise
263
+ * as separate Strings.
264
+ * @param promise The Promise to handle the obtained values. Promises are necessary in Native Modules
265
+ * to pass values back to the JavaScript.
266
+ */
267
+ @ReactMethod
268
+ public void getRefusedObjectives(@Nonnull Promise promise) {
269
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
270
+
271
+ if (blueConicClient != null) {
272
+ Collection<String> values = blueConicClient.getRefusedObjectives();
273
+ promise.resolve(Arguments.fromList(new ArrayList<String>(values)));
274
+ } else {
275
+ promise.resolve(Arguments.createArray());
276
+ }
277
+ }
278
+
279
+ /**
280
+ * Gets the refused objectives. The values are passed to the provided callback function
281
+ * as separate Strings.
282
+ * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
283
+ * to pass values back to the JavaScript.
284
+ */
285
+ @ReactMethod
286
+ public void getRefusedObjectivesWithCallback(@Nonnull Callback callback) {
287
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
288
+
289
+ if (blueConicClient != null) {
290
+ Collection<String> values = blueConicClient.getRefusedObjectives();
291
+ callback.invoke(values.toArray());
292
+ } else {
293
+ callback.invoke(new ArrayList<String>());
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Setter for the locale to get the parameters for. By default, the default locale configured in BlueConic is used.
299
+ * @param locale the locale, e.g. 'en_US'.
300
+ */
301
+ @ReactMethod
302
+ public void setLocale(@Nonnull String locale) {
303
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
304
+ if (blueConicClient != null) {
305
+ blueConicClient.setLocale(locale);
306
+ }
307
+ }
308
+
309
+ /**
310
+ * Gets the segments of the profile.
311
+ * To retrieve and update the Segments you have to register a pageview first.
312
+ * The values are passed to the provided promise
313
+ * as a list of Objects containing id and name.
314
+ * @param promise The Promise to handle the obtained values. Promises are necessary in Native Modules
315
+ * to pass values back to the JavaScript.
316
+ */
317
+ @ReactMethod
318
+ public void getSegments(@Nonnull Promise promise) {
319
+ promise.resolve(getFormattedSegments());
320
+ }
321
+
322
+ /**
323
+ * Gets the segments of the profile.
324
+ * To retrieve and update the Segments you have to register a pageview first.
325
+ * The values are passed to the provided promise
326
+ * as a list of Objects containing id and name.
327
+ * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
328
+ * to pass values back to the JavaScript.
329
+ */
330
+ @ReactMethod
331
+ public void getSegmentsWithCallback(@Nonnull Callback callback) {
332
+ callback.invoke(getFormattedSegments());
333
+ }
334
+
335
+ // MARK: ADDERS
336
+ /**
337
+ * Adds the given values to the specified profile property.
338
+ * @param property The profile property to which to add the values.
339
+ * @param values A ReadableArray containing Strings that will be added to the profile property.
340
+ */
341
+ @ReactMethod
342
+ public void addProfileValues(@Nonnull String property, @Nonnull ReadableArray values) {
343
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
344
+ if (blueConicClient != null) {
345
+ blueConicClient.addProfileValues(property, Arguments.toList(values));
346
+ }
347
+ }
348
+
349
+ /**
350
+ * Adds the given values to the specified profile property.
351
+ * @param property The profile property to which to add the values.
352
+ * @param value A ReadableArray containing Strings that will be added to the profile property.
353
+ */
354
+ @ReactMethod
355
+ public void addProfileValue(@Nonnull String property, @Nonnull String value) {
356
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
357
+ if (blueConicClient != null) {
358
+ blueConicClient.addProfileValue(property, value);
359
+ }
360
+ }
361
+
362
+ /**
363
+ * Adds an objective to the consented objectives list.
364
+ * @param objectiveId The id of the objective to add to consented objectives.
365
+ */
366
+ @ReactMethod
367
+ public void addConsentedObjective(@Nonnull String objectiveId) {
368
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
369
+ if (blueConicClient != null) {
370
+ blueConicClient.addConsentedObjective(objectiveId);
371
+ }
372
+ }
373
+
374
+ /**
375
+ * Adds an objective to the refused objectives list.
376
+ * @param objectiveId The id of the objective to add to refused objectives.
377
+ */
378
+ @ReactMethod
379
+ public void addRefusedObjective(@Nonnull String objectiveId) {
380
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
381
+ if (blueConicClient != null) {
382
+ blueConicClient.addRefusedObjective(objectiveId);
383
+ }
384
+ }
385
+
386
+ // MARK: SETTERS
387
+ /**
388
+ * Sets the given values for the specified profile property.
389
+ * @param property The profile property for which to set the values.
390
+ * @param values A ReadableArray containing Strings that will be set as the new values for the profile property.
391
+ */
392
+ @ReactMethod
393
+ public void setProfileValues(@Nonnull String property, @Nonnull ReadableArray values) {
394
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
395
+ if (blueConicClient != null) {
396
+ blueConicClient.setProfileValues(property, Arguments.toList(values));
397
+ }
398
+ }
399
+
400
+ /**
401
+ * Set the given value for the specified profile property.
402
+ * @param property The profile property for which to set the values.
403
+ * @param value A ReadableArray containing Strings that will be set as the new values for the profile property.
404
+ */
405
+ @ReactMethod
406
+ public void setProfileValue(@Nonnull String property, @Nonnull String value) {
407
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
408
+ if (blueConicClient != null) {
409
+ blueConicClient.setProfileValue(property, value);
410
+ }
411
+ }
412
+
413
+ /**
414
+ * Increments the given values to the specified profile property.
415
+ * @param property The profile property to which to increment the values.
416
+ * @param value A ReadableArray containing Strings that will be incremented to the profile property.
417
+ */
418
+ @ReactMethod
419
+ public void incrementProfileValue(@Nonnull String property, @Nonnull String value) {
420
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
421
+ if (blueConicClient != null) {
422
+ blueConicClient.incrementProfileValue(property, value);
423
+ }
424
+ }
425
+
426
+ /**
427
+ * Set the privacy legislation.
428
+ * @param privacyLegislation The privacy legislation.
429
+ */
430
+ @ReactMethod
431
+ public void setPrivacyLegislation(@Nonnull String privacyLegislation) {
432
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
433
+ if (blueConicClient != null) {
434
+ blueConicClient.setPrivacyLegislation(privacyLegislation);
435
+ }
436
+ }
437
+
438
+ /**
439
+ * Sets the given objectives for consented objectives.
440
+ * @param objectiveIds A ReadableArray containing IDs of Objectives that will be set as the new values for Consented objectives.
441
+ */
442
+ @ReactMethod
443
+ public void setConsentedObjectives(@Nonnull ReadableArray objectiveIds) {
444
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
445
+ if (blueConicClient != null) {
446
+ blueConicClient.setConsentedObjectives(Arguments.toList(objectiveIds));
447
+ }
448
+ }
449
+
450
+ /**
451
+ * Sets the given objectives for consented objectives.
452
+ * @param objectiveIds A ReadableArray containing IDs of Objectives that will be set as the new values for Consented objectives.
453
+ */
454
+ @ReactMethod
455
+ public void setRefusedObjectives(@Nonnull ReadableArray objectiveIds) {
456
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
457
+ if (blueConicClient != null) {
458
+ blueConicClient.setRefusedObjectives(Arguments.toList(objectiveIds));
459
+ }
460
+ }
461
+
462
+ /**
463
+ * Set enabled.
464
+ * Define to enable and disable the BlueConicClient
465
+ * To prevent or re-activate tracking data
466
+ * @param isEnabled to enable or disable the BlueConicClient.
467
+ */
468
+ @ReactMethod
469
+ public void setEnabled(@Nonnull Boolean isEnabled) {
470
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
471
+ if (blueConicClient != null) {
472
+ blueConicClient.setEnabled(isEnabled == null ? false : isEnabled.booleanValue());
473
+ }
474
+
475
+ }
476
+
477
+ /**
478
+ * Return is BlueConicClient enabled. The value is passed to the provided callback function as seperated Strings.
479
+ * @param promise The promise to handle the obtained value. Promises are necessary in Native Modules
480
+ * Native Modules to pass values back to the JavaScript.
481
+ */
482
+ @ReactMethod
483
+ public void isEnabled(@Nonnull Promise promise) {
484
+ final List<Boolean> result = new ArrayList<Boolean>();
485
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
486
+
487
+ if (blueConicClient != null) {
488
+ result.add(Boolean.valueOf(blueConicClient.isEnabled()));
489
+ }
490
+
491
+ promise.resolve(result);
492
+ }
493
+
494
+ /**
495
+ * Return is BlueConicClient enabled. The value is passed to the provided callback function as seperated Strings
496
+ * @param callback: The callback function to handle the obtained value. Callbacks are necessary in
497
+ * Native Modules to pass values back to the JavaScript.
498
+ */
499
+ @ReactMethod
500
+ public void isEnabledWithCallback(@Nonnull Callback callback) {
501
+ final List<Boolean> result = new ArrayList<Boolean>();
502
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
503
+
504
+ if (blueConicClient != null) {
505
+ result.add(Boolean.valueOf(blueConicClient.isEnabled()));
506
+ }
507
+
508
+ callback.invoke(result);
509
+ }
510
+
511
+ /**
512
+ * Return whether the BlueConic profile is part of the BlueConic segment. The value is passed to the provided callback function as Boolean.
513
+ * @param segmentId The id of the segment
514
+ * @param promise The promise to handle the obtained value. Promises are necessary in Native Modules
515
+ * Native Modules to pass values back to the JavaScript.
516
+ */
517
+ @ReactMethod
518
+ public void hasSegment(@Nonnull String segmentId, @Nonnull Promise promise) {
519
+ final List<Boolean> result = new ArrayList<Boolean>();
520
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
521
+
522
+ if (blueConicClient != null) {
523
+ result.add(Boolean.valueOf(blueConicClient.hasSegment(segmentId)));
524
+ }
525
+
526
+ promise.resolve(result);
527
+ }
528
+
529
+ /**
530
+ * Return whether the BlueConic profile is part of the BlueConic segment. The value is passed to the provided callback function as Boolean.
531
+ * @param segmentId The id of the segment
532
+ * @param callback: The callback function to handle the obtained value. Callbacks are necessary in
533
+ * Native Modules to pass values back to the JavaScript.
534
+ */
535
+ @ReactMethod
536
+ public void hasSegmentWithCallback(@Nonnull String segmentId, @Nonnull Callback callback) {
537
+ final List<Boolean> result = new ArrayList<Boolean>();
538
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
539
+
540
+ if (blueConicClient != null) {
541
+ result.add(Boolean.valueOf(blueConicClient.hasSegment(segmentId)));
542
+ }
543
+
544
+ callback.invoke(result);
545
+ }
546
+
547
+ // MARK: REGISTERS
548
+ /**
549
+ * Create Event.
550
+ * @param eventName The name of the event
551
+ * @param readableMap The readable map retrieved from React native
552
+ */
553
+ @ReactMethod
554
+ public void createEvent(@Nonnull String eventName, ReadableMap readableMap) {
555
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
556
+ final Map<String, Object> properties = readableMap.toHashMap();
557
+
558
+ if (blueConicClient != null) {
559
+ blueConicClient.createEventWithData(eventName, properties);
560
+ }
561
+ }
562
+
563
+ /**
564
+ * Create Event.
565
+ * @param eventName The name of the event
566
+ * @param readableMap The readable map retrieved from React native
567
+ * @param promise The promise to handle the obtained value. Promises are necessary in Native Modules
568
+ * Native Modules to pass values back to the JavaScript.
569
+ */
570
+ @ReactMethod
571
+ public void createEventSync(@Nonnull String eventName, ReadableMap readableMap, @Nonnull final Promise promise) {
572
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
573
+ final Map<String, Object> properties = readableMap.toHashMap();
574
+
575
+ if (blueConicClient != null) {
576
+ blueConicClient.createEventWithData(eventName, properties, new Runnable() {
577
+ @Override
578
+ public void run() {
579
+ promise.resolve(Arguments.createArray());
580
+ }
581
+ });
582
+ return;
583
+ }
584
+
585
+ promise.resolve(Arguments.createArray());
586
+ }
587
+
588
+ /**
589
+ * Create Event.
590
+ * @param eventName The name of the event
591
+ * @param readableMap The readable map retrieved from React native
592
+ * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
593
+ * to pass values back to the JavaScript.
594
+ */
595
+ @ReactMethod
596
+ public void createEventSyncWithCallback(@Nonnull String eventName, ReadableMap readableMap, @Nonnull final Callback callback) {
597
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
598
+ final Map<String, Object> properties = readableMap.toHashMap();
599
+
600
+ if (blueConicClient != null) {
601
+ blueConicClient.createEventWithData(eventName, properties, new Runnable() {
602
+ @Override
603
+ public void run() {
604
+ callback.invoke(Arguments.createArray());
605
+ }
606
+ });
607
+ return;
608
+ }
609
+
610
+ callback.invoke(Arguments.createArray());
611
+ }
612
+
613
+
614
+ /**
615
+ * Update sync the BlueConic Profile
616
+ */
617
+ @ReactMethod
618
+ public void updateProfile() {
619
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
620
+
621
+ if (blueConicClient != null) {
622
+ blueConicClient.updateProfile();
623
+ }
624
+ }
625
+
626
+ /**
627
+ * Update sync the BlueConic Profile
628
+ * @param promise The promise to handle the obtained value. Promises are necessary in Native Modules
629
+ * Native Modules to pass values back to the JavaScript.
630
+ */
631
+ @ReactMethod
632
+ public void updateProfileSync(@Nonnull final Promise promise) {
633
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
634
+
635
+ if (blueConicClient != null) {
636
+ blueConicClient.updateProfile(new Runnable() {
637
+ @Override
638
+ public void run() {
639
+ promise.resolve(Arguments.createArray());
640
+ }
641
+ });
642
+
643
+ return;
644
+ }
645
+
646
+ promise.resolve(Arguments.createArray());
647
+ }
648
+
649
+ /**
650
+ * Update sync the BlueConic Profile
651
+ * @param callback The Callback function to handle the obtained values. Callbacks are necessary in Native Modules
652
+ * to pass values back to the JavaScript.
653
+ */
654
+ @ReactMethod
655
+ public void updateProfileSyncWithCallback(@Nonnull final Callback callback) {
656
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
657
+
658
+ if (blueConicClient != null) {
659
+ blueConicClient.updateProfile(new Runnable() {
660
+ @Override
661
+ public void run() {
662
+ callback.invoke(Arguments.createArray());
663
+ }
664
+ });
665
+
666
+ return;
667
+ }
668
+
669
+ callback.invoke(Arguments.createArray());
670
+ }
671
+
672
+ /**
673
+ * Calls the createEvent method of the BlueConicClient to register a PAGEVIEW event. This must be called on every
674
+ * screen change as it triggers the BlueConic SDK to load all plugins (i.e. listeners, dialogues) for the screen.
675
+ * @param screenName The name of the screen.
676
+ */
677
+ @ReactMethod
678
+ public void registerPageView(@Nonnull String screenName) {
679
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
680
+ if (blueConicClient != null) {
681
+ // blueConicClient instance must have an activity or application
682
+ final Map<String, String> properties = new HashMap<>();
683
+ properties.put("screenName", screenName);
684
+ Activity activity = getCurrentActivity();
685
+ if (activity == null) {
686
+ activity = new Activity();
687
+ }
688
+
689
+ blueConicClient.createEvent("PAGEVIEW", properties, activity);
690
+ } else {
691
+ Log.e("BlueConic", "Unable to register a PAGEVIEW-event: Activity not available.");
692
+ }
693
+ }
694
+
695
+ /**
696
+ * Calls the createEvent method of the BlueConicClient to register a PAGEVIEW event. This must be called on every
697
+ * screen change as it triggers the BlueConic SDK to load all plugins (i.e. listeners, dialogues) for the screen.
698
+ * @param screenName The name of the screen.
699
+ */
700
+ @ReactMethod
701
+ public void registerPageViewSync(@Nonnull String screenName, @Nonnull final Promise promise) {
702
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
703
+ if (blueConicClient != null) {
704
+ // blueConicClient instance must have an activity or application
705
+ final Map<String, String> properties = new HashMap<>();
706
+ properties.put("screenName", screenName);
707
+ Activity activity = getCurrentActivity();
708
+ if (activity == null) {
709
+ activity = new Activity();
710
+ }
711
+
712
+ blueConicClient.createEvent("PAGEVIEW", properties, activity, new Runnable() {
713
+ @Override
714
+ public void run() {
715
+ promise.resolve(Arguments.createArray());
716
+ }
717
+ });
718
+ } else {
719
+ Log.e("BlueConic", "Unable to register a PAGEVIEW-event: Activity not available.");
720
+ promise.resolve(Arguments.createArray());
721
+ }
722
+ }
723
+
724
+ /**
725
+ * Calls the createEvent method of the BlueConicClient to register a PAGEVIEW event. This must be called on every
726
+ * screen change as it triggers the BlueConic SDK to load all plugins (i.e. listeners, dialogues) for the screen.
727
+ * @param screenName The name of the screen.
728
+ */
729
+ @ReactMethod
730
+ public void registerPageViewSyncCallback(@Nonnull String screenName, @Nonnull final Callback callback) {
731
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
732
+ if (blueConicClient != null) {
733
+ // blueConicClient instance must have an activity or application
734
+ final Map<String, String> properties = new HashMap<>();
735
+ properties.put("screenName", screenName);
736
+ Activity activity = getCurrentActivity();
737
+ if (activity == null) {
738
+ activity = new Activity();
739
+ }
740
+
741
+ blueConicClient.createEvent("PAGEVIEW", properties, activity, new Runnable() {
742
+ @Override
743
+ public void run() {
744
+ callback.invoke(Arguments.createArray());
745
+ }
746
+ });
747
+ } else {
748
+ Log.e("BlueConic", "Unable to register a PAGEVIEW-event: Activity not available.");
749
+ callback.invoke(Arguments.createArray());
750
+ }
751
+ }
752
+
753
+ /**
754
+ * Creates a ClickEvent for the given selector and publishes the event to BlueConic using the EventManager.
755
+ * @param selector The selector to identify the clicked component.
756
+ */
757
+ @ReactMethod
758
+ public void registerClickEvent(@Nonnull String selector) {
759
+ getBlueConicEventManagerInstance().publish(new ClickEvent(selector));
760
+ }
761
+
762
+ /**
763
+ * Creates a ClickEvent for the given selector and values, and publishes the event using the EventManager.
764
+ * @param selector The selector to identify the clicked component.
765
+ * @param values The values to pass to BlueConic as context of the event.
766
+ */
767
+ @ReactMethod
768
+ public void registerClickEventWithContext(@Nonnull String selector, @Nonnull ReadableArray values) {
769
+ getBlueConicEventManagerInstance().publish(new ClickEvent(selector, Arguments.toList(values)));
770
+ }
771
+
772
+ /**
773
+ * Creates a ClickEvent for the given selector and publishes the event to BlueConic using the EventManager.
774
+ * @param selector The selector to identify the clicked component.
775
+ */
776
+ @ReactMethod
777
+ public void registerFormSubmitEvent(@Nonnull String selector) {
778
+ getBlueConicEventManagerInstance().publish(new FormSubmitEvent(selector));
779
+ }
780
+
781
+ /**
782
+ * Creates a ClickEvent for the given selector and values, and publishes the event using the EventManager.
783
+ * @param selector The selector to identify the clicked component.
784
+ * @param values The values to pass to BlueConic as context of the event.
785
+ */
786
+ @ReactMethod
787
+ public void registerFormSubmitEventWithContext(@Nonnull String selector, @Nonnull ReadableArray values) {
788
+ getBlueConicEventManagerInstance().publish(new FormSubmitEvent(selector, Arguments.toList(values)));
789
+ }
790
+
791
+ /**
792
+ * Creates an UpdateContentEvent for the given selector and value, and publishes the event using the EventManager.
793
+ * @param selector The selector to identify the component with updated values.
794
+ * @param value The value to be passed on to BlueConic.
795
+ */
796
+ @ReactMethod
797
+ public void registerUpdateContentEvent(@Nonnull String selector, @Nonnull String value) {
798
+ UpdateContentEvent event = new UpdateContentEvent(selector, value);
799
+ getBlueConicEventManagerInstance().publish(event);
800
+ }
801
+
802
+ /**
803
+ * Creates an UpdateValuesEvent for the given selector and value, and publishes the event using the EventManager.
804
+ * @param selector The selector to identify the component with updated values.
805
+ * @param value The value to be passed on to BlueConic.
806
+ */
807
+ @ReactMethod
808
+ public void registerUpdateValuesEvent(@Nonnull String selector, @Nonnull String value) {
809
+ UpdateValuesEvent event = new UpdateValuesEvent(selector, Collections.singletonList(value));
810
+ getBlueConicEventManagerInstance().publish(event);
811
+ }
812
+
813
+ /**
814
+ * Creates an AdvancedEvent with the given name and values, and publishes the event using the EventManager.
815
+ * @param name The name to identify the event.
816
+ * @param values The values to pass to BlueConic as context of the event.
817
+ */
818
+ @ReactMethod
819
+ public void registerAdvancedEvent(@Nonnull String name, @Nonnull ReadableArray values) {
820
+ AdvancedEvent event = new AdvancedEvent(name, Arguments.toList(values));
821
+ getBlueConicEventManagerInstance().publish(event);
822
+ }
823
+
824
+
825
+
826
+ /**
827
+ * Destroys all active BlueConic plugins (i.e. instances of listeners and dialogues). This method must be called
828
+ * in the onPause of an activity if the app targets Android API versions before API 14. It should also be called if
829
+ * one switches screens in the app without calling the onPause of the previous Activity.
830
+ *
831
+ */
832
+ @ReactMethod
833
+ public void destroyPlugins() {
834
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
835
+ if (blueConicClient != null) {
836
+ blueConicClient.destroyPlugins();
837
+ }
838
+ }
839
+
840
+ /**
841
+ * Sends an event to the BlueConic server, indicating that a certain interaction was viewed, clicked, or converted for.
842
+ * @param eventType The event type to register for the interaction. Possible events are "VIEW", "CLICK" and "CONVERSION".
843
+ * @param interactionId The unique identifier of the interaction.
844
+ */
845
+ @ReactMethod
846
+ public void registerDialogueEvent(@Nonnull String eventType, @Nonnull String interactionId) {
847
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
848
+ if (blueConicClient != null) {
849
+ final Map<String, String> interactionIdMap = new HashMap<>();
850
+ interactionIdMap.put("interactionId", interactionId);
851
+ blueConicClient.createEvent(eventType, interactionIdMap);
852
+ }
853
+ }
854
+
855
+
856
+ /**
857
+ * Returns an instance of the BlueConicClient
858
+ * @return BlueConicClient
859
+ */
860
+ private BlueConicClient getBlueConicClientInstance() {
861
+ // Retrieve current Activity from ReactContextBaseJavaModule
862
+ final Activity currentActivity = getCurrentActivity();
863
+ if (currentActivity != null) {
864
+ // Activity found and return a BlueConicClient instance
865
+ BlueConicClient instance = BlueConicClientFactory.INSTANCE.getInstance(currentActivity);
866
+ //Set platform information
867
+ BlueConicClientImpl implInstance = (BlueConicClientImpl) instance;
868
+ //implInstance.setPlatformInformation(BuildConfig.PLATFORM_NAME, BuildConfig.PLATFORM_VERSION);
869
+ return instance;
870
+ }
871
+
872
+ return null;
873
+ }
874
+
875
+ /**
876
+ * Returns an instance of the BlueConicEventManager
877
+ * @return BlueConicClient
878
+ */
879
+ private BlueConicEventManager getBlueConicEventManagerInstance() {
880
+ return BlueConicEventFactory.INSTANCE.getInstance(getBlueConicClientInstance());
881
+ }
882
+
883
+ private WritableArray getFormattedSegments() {
884
+ final WritableArray result = new WritableNativeArray();
885
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
886
+
887
+ if (blueConicClient == null) {
888
+ return result;
889
+ }
890
+ final Collection<BlueConicClient.Segment> segments = blueConicClient.getSegments();
891
+
892
+ for (BlueConicClient.Segment segment : segments) {
893
+ final WritableMap item = new WritableNativeMap();
894
+ item.putString("id", segment.getId());
895
+ item.putString("name", segment.getName());
896
+ result.pushMap(item);
897
+ }
898
+
899
+ return result;
900
+ }
901
+
902
+ /**
903
+ * Static method that is called by the BlueConicInteraction when it receives the parameters of the dialogue,
904
+ * and when the dialogue is destroyed by the BlueConic SDK. An event is published to which the JavaScript of the
905
+ * app should subscribe.
906
+ * @param properties The properties of the dialogues as received from BlueConic.
907
+ * @param eventName The name of the event to be published.
908
+ */
909
+ static void publishDialogueEvent(@Nonnull Map<String, Object> properties, String eventName) {
910
+ WritableMap map = Arguments.makeNativeMap(properties);
911
+
912
+ if (helper != null) {
913
+ helper
914
+ .getReactContext()
915
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
916
+ .emit(eventName, map);
917
+ }
918
+ }
871
919
  }