@blueconic/blueconic-react-native 5.0.0 → 5.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.
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
10
10
  s.license = { :type => 'Commercial' }
11
11
 
12
12
  s.authors = { 'BlueConic' => 'info@blueconic.com' }
13
- s.platform = :ios, "12.0"
13
+ s.platform = :ios, "13.0"
14
14
  s.homepage = "https://blueconic.com"
15
15
  s.source = { :http => "https://registry.npmjs.org/@blueconic/blueconic-react-native/-/blueconic-react-native-"+ package['version'] + ".tgz" }
16
16
 
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  `@blueconic/blueconic-react-native` adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
+ ## [5.1.0] 2025-10-01
6
+
7
+ ### Added
8
+ - React-Android & iOS: Added Recommendations as Event Dialogue plugin support.
9
+ - React-Android & iOS: Added additional event for tracking content store Recommendations interactions.
10
+
11
+ ### Changed
12
+ - Updated support for React Native 0.8x version
13
+ - React-Android: Updated the SDK target to API 36 and Kotlin dependencies.
14
+ - React-iOS: Updated the deployment target to iOS 13 and Swift dependencies.
15
+ - React-Android & iOS: Changed the increment value method for the profile to accept Integer values instead of String.
16
+
17
+ ### Fixed
18
+ - React-Android: Fixed issue with the SDK not correctly removing existing plugins when a PAGEVIEW event is triggered.
19
+ - React-iOS: Fixed issue where the `publish(...)` method did not invoke the callback on success.
20
+
5
21
  ## [5.0.0] 2025-07-11
6
22
 
7
23
  ### Added
@@ -1,7 +1,7 @@
1
1
 
2
2
  buildscript {
3
3
  ext {
4
- kotlin_version = '1.9.10'
4
+ kotlin_version = '2.1.21'
5
5
  }
6
6
  repositories {
7
7
  google()
@@ -9,7 +9,7 @@ buildscript {
9
9
  }
10
10
 
11
11
  dependencies {
12
- classpath 'com.android.tools.build:gradle:7.4.2'
12
+ classpath 'com.android.tools.build:gradle:8.11.0'
13
13
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
14
  }
15
15
  }
@@ -18,16 +18,16 @@ apply plugin: 'com.android.library'
18
18
  apply plugin: 'org.jetbrains.kotlin.android'
19
19
 
20
20
  android {
21
- compileSdk 35
21
+ compileSdk 36
22
22
 
23
23
  namespace 'com.blueconic.reactnative'
24
24
  defaultConfig {
25
25
  minSdkVersion 21
26
- targetSdkVersion 35
27
- versionCode 500
28
- versionName "5.0.0"
26
+ targetSdkVersion 36
27
+ versionCode 510
28
+ versionName "5.1.0"
29
29
  buildConfigField 'String', 'PLATFORM_NAME', "\"React Native\""
30
- buildConfigField 'String', 'PLATFORM_VERSION', "\"5.0.0\""
30
+ buildConfigField 'String', 'PLATFORM_VERSION', "\"5.1.0\""
31
31
  }
32
32
  lintOptions {
33
33
  abortOnError false
@@ -39,6 +39,10 @@ android {
39
39
  sourceCompatibility JavaVersion.VERSION_17
40
40
  targetCompatibility JavaVersion.VERSION_17
41
41
  }
42
+
43
+ buildFeatures {
44
+ buildConfig true
45
+ }
42
46
  }
43
47
 
44
48
  repositories {
@@ -48,12 +52,12 @@ repositories {
48
52
 
49
53
  dependencies {
50
54
  compileOnly 'com.facebook.react:react-android:+'
51
- implementation 'com.blueconic:blueconic-android-lib:7.0.0'
55
+ implementation 'com.blueconic:blueconic-android-lib:7.1.0'
52
56
 
53
- testImplementation 'androidx.core:core-ktx:1.13.1'
57
+ testImplementation 'androidx.core:core-ktx:1.17.0'
54
58
  testImplementation 'junit:junit:4.13.2'
55
- testImplementation "io.mockk:mockk:1.12.5"
59
+ testImplementation "io.mockk:mockk:1.14.5"
56
60
  testImplementation 'com.facebook.react:react-android:+'
57
- testImplementation 'com.blueconic:blueconic-android-lib:7.0.0'
58
- implementation "org.jetbrains.kotlin:kotlin-reflect:1.9.24"
61
+ testImplementation 'com.blueconic:blueconic-android-lib:7.1.0'
62
+ implementation "org.jetbrains.kotlin:kotlin-reflect:2.1.21"
59
63
  }
@@ -1,4 +1,4 @@
1
- org.gradle.jvmargs=-Xmx2048M
1
+ org.gradle.jvmargs=-Xmx4096M
2
2
  org.gradle.parallel=true
3
3
  android.useAndroidX=true
4
4
  android.enableJetifier=true
@@ -14,6 +14,7 @@ import com.blueconic.impl.configuration.BlueConicConfiguration;
14
14
  import com.blueconic.plugin.events.Event;
15
15
  import com.blueconic.plugin.events.EventHandler;
16
16
  import com.blueconic.plugin.events.PropertiesDialogueEvent;
17
+ import com.blueconic.plugin.events.RecommendationsDialogueEvent;
17
18
  import com.facebook.react.bridge.*;
18
19
  import com.facebook.react.modules.core.DeviceEventManagerModule;
19
20
  import org.jetbrains.annotations.NotNull;
@@ -530,8 +531,12 @@ public class BlueConicClientModule extends ReactContextBaseJavaModule {
530
531
  @ReactMethod
531
532
  public void setConsentedObjectives(@Nonnull ReadableArray objectiveIds) {
532
533
  final BlueConicClient blueConicClient = getBlueConicClientInstance();
534
+ List<String> objectiveValues = new ArrayList<>();
535
+ for (Object value : objectiveIds.toArrayList()) {
536
+ objectiveValues.add((String) value);
537
+ }
533
538
  if (blueConicClient != null) {
534
- blueConicClient.getProfile().setConsentedObjectives(toList(objectiveIds));
539
+ blueConicClient.getProfile().setConsentedObjectives(objectiveValues);
535
540
  }
536
541
  }
537
542
 
@@ -543,8 +548,12 @@ public class BlueConicClientModule extends ReactContextBaseJavaModule {
543
548
  @ReactMethod
544
549
  public void setRefusedObjectives(@Nonnull ReadableArray objectiveIds) {
545
550
  final BlueConicClient blueConicClient = getBlueConicClientInstance();
551
+ List<String> objectiveValues = new ArrayList<>();
552
+ for (Object value : objectiveIds.toArrayList()) {
553
+ objectiveValues.add((String) value);
554
+ }
546
555
  if (blueConicClient != null) {
547
- blueConicClient.getProfile().setRefusedObjectives(toList(objectiveIds));
556
+ blueConicClient.getProfile().setRefusedObjectives(objectiveValues);
548
557
  }
549
558
  }
550
559
 
@@ -652,8 +661,12 @@ public class BlueConicClientModule extends ReactContextBaseJavaModule {
652
661
  @ReactMethod
653
662
  public void addProfileValues(@Nonnull String property, @Nonnull ReadableArray values) {
654
663
  final BlueConicClient blueConicClient = getBlueConicClientInstance();
664
+ List<String> profileValues = new ArrayList<>();
665
+ for (Object value : values.toArrayList()) {
666
+ profileValues.add((String) value);
667
+ }
655
668
  if (blueConicClient != null) {
656
- blueConicClient.getProfile().addValues(property, toList(values), null);
669
+ blueConicClient.getProfile().addValues(property, profileValues, null);
657
670
  }
658
671
  }
659
672
 
@@ -680,8 +693,12 @@ public class BlueConicClientModule extends ReactContextBaseJavaModule {
680
693
  @ReactMethod
681
694
  public void setProfileValues(@Nonnull String property, @Nonnull ReadableArray values) {
682
695
  final BlueConicClient blueConicClient = getBlueConicClientInstance();
696
+ List<String> profileValues = new ArrayList<>();
697
+ for (Object value : values.toArrayList()) {
698
+ profileValues.add((String) value);
699
+ }
683
700
  if (blueConicClient != null) {
684
- blueConicClient.getProfile().setValues(property, toList(values), null);
701
+ blueConicClient.getProfile().setValues(property, profileValues, null);
685
702
  }
686
703
  }
687
704
 
@@ -692,7 +709,7 @@ public class BlueConicClientModule extends ReactContextBaseJavaModule {
692
709
  * @param value A ReadableArray containing Strings that will be incremented to the profile property.
693
710
  */
694
711
  @ReactMethod
695
- public void incrementProfileValue(@Nonnull String property, @Nonnull String value) {
712
+ public void incrementProfileValue(@Nonnull String property, @Nonnull Integer value) {
696
713
  final BlueConicClient blueConicClient = getBlueConicClientInstance();
697
714
  if (blueConicClient != null) {
698
715
  blueConicClient.getProfile().incrementValue(property, value, null);
@@ -1358,12 +1375,76 @@ public class BlueConicClientModule extends ReactContextBaseJavaModule {
1358
1375
  }
1359
1376
  }
1360
1377
 
1378
+ @ReactMethod
1379
+ public void createRecommendationEvent(@Nonnull String storeId, @Nonnull String action, @Nonnull ReadableArray itemIds) {
1380
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
1381
+ List<String> itemIdsValues = new ArrayList<>();
1382
+ for (Object value : itemIds.toArrayList()) {
1383
+ itemIdsValues.add((String) value);
1384
+ }
1385
+
1386
+ if (blueConicClient != null) {
1387
+ blueConicClient.createRecommendationEvent(storeId, action, itemIdsValues, null);
1388
+ }
1389
+ }
1390
+
1391
+ @ReactMethod
1392
+ public void createRecommendationEventAsync(@Nonnull String storeId, @Nonnull String action, @Nonnull ReadableArray itemIds, @Nonnull final Promise promise) {
1393
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
1394
+ List<String> itemIdsValues = new ArrayList<>();
1395
+ for (Object value : itemIds.toArrayList()) {
1396
+ itemIdsValues.add((String) value);
1397
+ }
1398
+
1399
+ if (blueConicClient != null) {
1400
+ blueConicClient.createRecommendationEvent(storeId, action, itemIdsValues, new com.blueconic.Callback() {
1401
+ @Override
1402
+ public void onSuccess() {
1403
+ promise.resolve(getWritableArray());
1404
+ }
1405
+
1406
+ @Override
1407
+ public void onError(@NotNull com.blueconic.Error error) {
1408
+ promise.resolve(getWritableArray());
1409
+ }
1410
+ });
1411
+ } else {
1412
+ promise.resolve(getWritableArray());
1413
+ }
1414
+ }
1415
+
1416
+ @ReactMethod
1417
+ public void createRecommendationEventWithCallback(@Nonnull String storeId, @Nonnull String action, @Nonnull ReadableArray itemIds, @Nonnull final Callback callback) {
1418
+ final BlueConicClient blueConicClient = getBlueConicClientInstance();
1419
+ List<String> itemIdsValues = new ArrayList<>();
1420
+ for (Object value : itemIds.toArrayList()) {
1421
+ itemIdsValues.add((String) value);
1422
+ }
1423
+
1424
+ if (blueConicClient != null) {
1425
+ blueConicClient.createRecommendationEvent(storeId, action, itemIdsValues, new com.blueconic.Callback() {
1426
+ @Override
1427
+ public void onSuccess() {
1428
+ callback.invoke(true, null);
1429
+ }
1430
+
1431
+ @Override
1432
+ public void onError(@NotNull com.blueconic.Error error) {
1433
+ callback.invoke(false, error.toString());
1434
+ }
1435
+ });
1436
+ } else {
1437
+ callback.invoke(false, "InternalError");
1438
+ }
1439
+ }
1440
+
1361
1441
  @ReactMethod
1362
1442
  public void subscribe(@Nonnull String eventName, boolean onlyOnce, @Nonnull String identifier) {
1363
1443
  final BlueConicClient blueConicClient = getBlueConicClientInstance();
1364
1444
 
1365
1445
  EventHandler eventHandler = switch (eventName) {
1366
1446
  case "propertiesDialogueEvent" -> new PropertiesDialogueHandler(eventName);
1447
+ case "recommendationsDialogueEvent" -> new RecommendationsDialogueHandler(eventName);
1367
1448
  default -> event -> {};
1368
1449
  };
1369
1450
 
@@ -1383,11 +1464,13 @@ public class BlueConicClientModule extends ReactContextBaseJavaModule {
1383
1464
  */
1384
1465
  @ReactMethod
1385
1466
  public void publishClickEvent(@Nonnull String selector, ReadableArray values) {
1386
- List<String> contextValues;
1467
+ List<String> contextValues = new ArrayList<>();
1387
1468
  if (values == null) {
1388
1469
  contextValues = emptyList();
1389
1470
  } else {
1390
- contextValues = toList(values);
1471
+ for (Object value : values.toArrayList()) {
1472
+ contextValues.add((String) value);
1473
+ }
1391
1474
  }
1392
1475
  getBlueConicClientInstance().getEventManager().publishClickEvent(selector, contextValues, null);
1393
1476
  }
@@ -1399,11 +1482,13 @@ public class BlueConicClientModule extends ReactContextBaseJavaModule {
1399
1482
  */
1400
1483
  @ReactMethod
1401
1484
  public void publishClickEventWithCallback(@Nonnull String selector, ReadableArray values, @Nonnull final Callback callback) {
1402
- List<String> contextValues;
1485
+ List<String> contextValues = new ArrayList<>();
1403
1486
  if (values == null) {
1404
1487
  contextValues = emptyList();
1405
1488
  } else {
1406
- contextValues = toList(values);
1489
+ for (Object value : values.toArrayList()) {
1490
+ contextValues.add((String) value);
1491
+ }
1407
1492
  }
1408
1493
  getBlueConicClientInstance().getEventManager().publishClickEvent(selector, contextValues, new com.blueconic.Callback() {
1409
1494
  @Override
@@ -1425,11 +1510,13 @@ public class BlueConicClientModule extends ReactContextBaseJavaModule {
1425
1510
  */
1426
1511
  @ReactMethod
1427
1512
  public void publishFormSubmitEvent(@Nonnull String selector, ReadableArray values) {
1428
- List<String> contextValues;
1513
+ List<String> contextValues = new ArrayList<>();
1429
1514
  if (values == null) {
1430
1515
  contextValues = emptyList();
1431
1516
  } else {
1432
- contextValues = toList(values);
1517
+ for (Object value : values.toArrayList()) {
1518
+ contextValues.add((String) value);
1519
+ }
1433
1520
  }
1434
1521
  getBlueConicClientInstance().getEventManager().publishFormSubmitEvent(selector, contextValues, null);
1435
1522
  }
@@ -1441,11 +1528,13 @@ public class BlueConicClientModule extends ReactContextBaseJavaModule {
1441
1528
  */
1442
1529
  @ReactMethod
1443
1530
  public void publishFormSubmitEventWithCallback(@Nonnull String selector, ReadableArray values, @Nonnull final Callback callback) {
1444
- List<String> contextValues;
1531
+ List<String> contextValues = new ArrayList<>();
1445
1532
  if (values == null) {
1446
1533
  contextValues = emptyList();
1447
1534
  } else {
1448
- contextValues = toList(values);
1535
+ for (Object value : values.toArrayList()) {
1536
+ contextValues.add((String) value);
1537
+ }
1449
1538
  }
1450
1539
  getBlueConicClientInstance().getEventManager().publishFormSubmitEvent(selector, contextValues, new com.blueconic.Callback() {
1451
1540
  @Override
@@ -1532,7 +1621,11 @@ public class BlueConicClientModule extends ReactContextBaseJavaModule {
1532
1621
  */
1533
1622
  @ReactMethod
1534
1623
  public void publishAdvancedEvent(@Nonnull String name, @Nonnull ReadableArray values) {
1535
- getBlueConicClientInstance().getEventManager().publishAdvancedEvent(name, toList(values), null);
1624
+ List<String> contextValues = new ArrayList<>();
1625
+ for (Object value : values.toArrayList()) {
1626
+ contextValues.add((String) value);
1627
+ }
1628
+ getBlueConicClientInstance().getEventManager().publishAdvancedEvent(name, contextValues, null);
1536
1629
  }
1537
1630
 
1538
1631
  /**
@@ -1543,7 +1636,11 @@ public class BlueConicClientModule extends ReactContextBaseJavaModule {
1543
1636
  */
1544
1637
  @ReactMethod
1545
1638
  public void publishAdvancedEventWithCallback(@Nonnull String name, @Nonnull ReadableArray values, @Nonnull final Callback callback) {
1546
- getBlueConicClientInstance().getEventManager().publishAdvancedEvent(name, toList(values), new com.blueconic.Callback() {
1639
+ List<String> contextValues = new ArrayList<>();
1640
+ for (Object value : values.toArrayList()) {
1641
+ contextValues.add((String) value);
1642
+ }
1643
+ getBlueConicClientInstance().getEventManager().publishAdvancedEvent(name, contextValues, new com.blueconic.Callback() {
1547
1644
  @Override
1548
1645
  public void onSuccess() {
1549
1646
  callback.invoke(true, null);
@@ -1769,4 +1866,23 @@ class PropertiesDialogueHandler implements EventHandler {
1769
1866
  values.put("data", propertiesDialogueEvent.getData());
1770
1867
  BlueConicClientModule.publishDialogueEvent(values, eventName);
1771
1868
  }
1869
+ }
1870
+
1871
+ class RecommendationsDialogueHandler implements EventHandler {
1872
+ private final String eventName;
1873
+
1874
+ RecommendationsDialogueHandler(String eventName) {
1875
+ this.eventName = eventName;
1876
+ }
1877
+
1878
+ @Override
1879
+ public void handleEvent(@NotNull Event event) {
1880
+ RecommendationsDialogueEvent propertiesDialogueEvent = (RecommendationsDialogueEvent) event;
1881
+ Map<String, Object> values = new HashMap<>();
1882
+ values.put("variantId", propertiesDialogueEvent.getVariantId());
1883
+ values.put("position", propertiesDialogueEvent.getPosition());
1884
+ values.put("storeId", propertiesDialogueEvent.getStoreId());
1885
+ values.put("recommendations", propertiesDialogueEvent.getRecommendations());
1886
+ BlueConicClientModule.publishDialogueEvent(values, eventName);
1887
+ }
1772
1888
  }
@@ -403,7 +403,7 @@ class BlueConicClientModuleTests {
403
403
  fun `incrementProfileValue should increment value to profile`() {
404
404
  // Given
405
405
  val property = "testProperty"
406
- val value = "testValue"
406
+ val value = 1
407
407
  // When
408
408
  module.incrementProfileValue(property, value)
409
409
  // Then
@@ -572,6 +572,42 @@ class BlueConicClientModuleTests {
572
572
  verify { blueConicClient.createTimelineEventById(timelineId, timelineEventType, Date(dateTime), any<HashMap<String, Any>>(), any()) }
573
573
  }
574
574
 
575
+ @Test
576
+ fun `createRecommendationsEvent should send a recommendations event to platform`() {
577
+ // Given
578
+ val storeId = "id"
579
+ val action = "view"
580
+ val itemId = MockWritableArray().apply { pushString("item1") }
581
+ // When
582
+ module.createRecommendationEvent(storeId, action, itemId)
583
+ // Then
584
+ verify { blueConicClient.createRecommendationEvent(storeId, action, any<List<String>>(), null) }
585
+ }
586
+
587
+ @Test
588
+ fun `createRecommendationsEventAsync should send a recommendations event to platform`() {
589
+ // Given
590
+ val storeId = "id"
591
+ val action = "view"
592
+ val itemId = MockWritableArray().apply { pushString("item1") }
593
+ // When
594
+ module.createRecommendationEventAsync(storeId, action, itemId, MockPromise())
595
+ // Then
596
+ verify { blueConicClient.createRecommendationEvent(storeId, action, any<List<String>>(), any()) }
597
+ }
598
+
599
+ @Test
600
+ fun `createRecommendationsEventWithCallback should send a recommendations event to platform`() {
601
+ // Given
602
+ val storeId = "id"
603
+ val action = "view"
604
+ val itemId = MockWritableArray().apply { pushString("item1") }
605
+ // When
606
+ module.createRecommendationEventWithCallback(storeId, action, itemId, MockCallback())
607
+ // Then
608
+ verify { blueConicClient.createRecommendationEvent(storeId, action, any<List<String>>(), any()) }
609
+ }
610
+
575
611
  @Test
576
612
  fun `publishClickEvent should send a click event to platform`() {
577
613
  // Given
package/index.js CHANGED
@@ -47,6 +47,7 @@ export { BlueConicConfiguration };
47
47
 
48
48
  class EventName {
49
49
  static PropertiesDialogue = "propertiesDialogueEvent"
50
+ static RecommendationsDialogue = "recommendationsDialogueEvent"
50
51
  };
51
52
 
52
53
  export { EventName };
@@ -57,7 +58,14 @@ class PropertiesDialogueEvent {
57
58
  data;
58
59
  };
59
60
 
60
- export { PropertiesDialogueEvent };
61
+ class RecommendationsDialogueEvent {
62
+ variantId;
63
+ position;
64
+ storeId;
65
+ recommendations;
66
+ };
67
+
68
+ export { PropertiesDialogueEvent, RecommendationsDialogueEvent };
61
69
 
62
70
  const { BlueConicClient } = NativeModules;
63
71
 
@@ -170,7 +170,7 @@
170
170
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
171
171
  GCC_WARN_UNUSED_FUNCTION = YES;
172
172
  GCC_WARN_UNUSED_VARIABLE = YES;
173
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
173
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
174
174
  MTL_ENABLE_DEBUG_INFO = YES;
175
175
  ONLY_ACTIVE_ARCH = YES;
176
176
  SDKROOT = iphoneos;
@@ -216,7 +216,7 @@
216
216
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
217
217
  GCC_WARN_UNUSED_FUNCTION = YES;
218
218
  GCC_WARN_UNUSED_VARIABLE = YES;
219
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
219
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
220
220
  MTL_ENABLE_DEBUG_INFO = NO;
221
221
  SDKROOT = iphoneos;
222
222
  VALIDATE_PRODUCT = YES;
@@ -8,13 +8,12 @@
8
8
 
9
9
  RCT_EXTERN_METHOD(initialize:(NSDictionary *)properties withCallback:(RCTResponseSenderBlock)callback)
10
10
 
11
- RCT_EXTERN_METHOD(getProfileId:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
11
+ RCT_EXTERN_METHOD(getProfileIdAsync:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
12
+ RCT_EXTERN_METHOD(getProfileIdWithCallback:(RCTResponseSenderBlock)callback)
12
13
 
13
14
  RCT_EXTERN_METHOD(getProfileValueAsync:(NSString *)property withResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
14
15
  RCT_EXTERN_METHOD(getProfileValuesAsync:(NSString *)property withResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
15
16
 
16
- RCT_EXTERN_METHOD(getProfileIdWithCallback:(RCTResponseSenderBlock)callback)
17
-
18
17
  RCT_EXTERN_METHOD(getProfileValueWithCallback:(NSString *)property withCallback:(RCTResponseSenderBlock)callback)
19
18
  RCT_EXTERN_METHOD(getProfileValuesWithCallback:(NSString *)property withCallback:(RCTResponseSenderBlock)callback)
20
19
 
@@ -38,7 +37,7 @@ RCT_EXTERN_METHOD(addProfileValues:(NSString *)property withValues:(NSArray *)va
38
37
  RCT_EXTERN_METHOD(setProfileValue:(NSString *)property withValue:(NSString *)value)
39
38
  RCT_EXTERN_METHOD(setProfileValues:(NSString *)property withValues:(NSArray *)values)
40
39
 
41
- RCT_EXTERN_METHOD(incrementProfileValue:(NSString *)property withValue:(NSString *)value)
40
+ RCT_EXTERN_METHOD(incrementProfileValue:(NSString *)property withValue:(int)value)
42
41
 
43
42
  RCT_EXTERN_METHOD(setPrivacyLegislation:(NSString *)privacyLegislation)
44
43
 
@@ -93,6 +92,10 @@ RCT_EXTERN_METHOD(createTimelineEventById:(NSString *)eventId withType:(NSString
93
92
  RCT_EXTERN_METHOD(createTimelineEventByIdAsync:(NSString *)eventId withType:(NSString *)eventType withDate:(NSDate *)eventDate withProperties:(NSDictionary *)properties withResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
94
93
  RCT_EXTERN_METHOD(createTimelineEventByIdWithCallback:(NSString *)eventId withType:(NSString *)eventType withDate:(NSDate *)eventDate withProperties:(NSDictionary *)properties withCallback:(RCTResponseSenderBlock)callback)
95
94
 
95
+ RCT_EXTERN_METHOD(createRecommendationEvent:(NSString *)storeId withAction:(NSString *)action withItemIds:(NSArray *)itemIds)
96
+ RCT_EXTERN_METHOD(createRecommendationEventAsync:(NSString *)storeId withAction:(NSString *)action withItemIds:(NSArray *)itemIds withResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
97
+ RCT_EXTERN_METHOD(createRecommendationEventWithCallback:(NSString *)storeId withAction:(NSString *)action withItemIds:(NSArray *)itemIds withCallback:(RCTResponseSenderBlock)callback)
98
+
96
99
  RCT_EXTERN_METHOD(subscribe:(NSString *)eventName withOnlyOnce:(BOOL)onlyOnce withIdentifier:(NSString *)identifier)
97
100
  RCT_EXTERN_METHOD(unsubscribe:(NSString *)identifier)
98
101
 
@@ -9,7 +9,7 @@ import BlueConicClient
9
9
  @objc(BlueConicClientModule)
10
10
  class BlueConicClientModule: RCTEventEmitter {
11
11
  private static var platformName: String = "React Native"
12
- private static var platformVersion: String = "5.0.0"
12
+ private static var platformVersion: String = "5.1.0"
13
13
  private static var moduleInstance: BlueConicClientModule?
14
14
  private static var hasListeners: Bool?
15
15
 
@@ -274,7 +274,7 @@ class BlueConicClientModule: RCTEventEmitter {
274
274
  - parameter property: The profile property to which to increment the values.
275
275
  - parameter values: An Array containing Strings to be incremented to the profile property.
276
276
  */
277
- @objc func incrementProfileValue(_ property: String, withValue value: String) -> Void {
277
+ @objc func incrementProfileValue(_ property: String, withValue value: Int) -> Void {
278
278
  self.getBlueConicClientInstance().getProfile().incrementValue(property, value: value)
279
279
  }
280
280
 
@@ -571,18 +571,41 @@ class BlueConicClientModule: RCTEventEmitter {
571
571
  })
572
572
  }
573
573
 
574
+ /**
575
+ Calls the createRecommendationEvent method of the BlueConicClient.
576
+ */
577
+ @objc func createRecommendationEvent(_ storeId: String, withAction action: String, withItemIds itemIds: [String]) -> Void {
578
+ self.getBlueConicClientInstance().createRecommendationEvent(storeId: storeId, action: action, itemIds: itemIds, callback: nil)
579
+ }
580
+ @objc func createRecommendationEventAsync(_ storeId: String, withAction action: String, withItemIds itemIds: [String], withResolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
581
+ self.getBlueConicClientInstance().createRecommendationEvent(storeId: storeId, action: action, itemIds: itemIds, callback: { result in
582
+ resolve([])
583
+ })
584
+ }
585
+ @objc func createRecommendationEventWithCallback(_ storeId: String, withAction action: String, withItemIds itemIds: [String], withCallback callback: @escaping RCTResponseSenderBlock) -> Void {
586
+ self.getBlueConicClientInstance().createRecommendationEvent(storeId: storeId, action: action, itemIds: itemIds, callback: { result in
587
+ if result.success {
588
+ callback([true, nil])
589
+ } else if let error = result.error {
590
+ callback([false, error.nsError.localizedDescription])
591
+ }
592
+ })
593
+ }
594
+
574
595
  @objc func subscribe(_ eventName: String, withOnlyOnce onlyOnce: Bool, withIdentifier identifier: String) -> Void {
575
596
  let eventHandler: EventHandler
576
597
 
577
598
  switch eventName {
578
599
  case "propertiesDialogueEvent":
579
600
  eventHandler = PropertiesDialogueHandler(eventName: eventName)
601
+ case "recommendationsDialogueEvent":
602
+ eventHandler = RecommendationsDialogueHandler(eventName: eventName)
580
603
  default:
581
604
  eventHandler = DefaultEventHandler()
582
605
  }
583
606
 
584
607
  self.getBlueConicClientInstance().getEventManager().subscribe(
585
- BlueConicEventManager.EventName.propertiesDialogue,
608
+ eventName,
586
609
  callbackObject: eventHandler,
587
610
  onlyOnce: onlyOnce,
588
611
  identifier: identifier
@@ -794,7 +817,7 @@ class BlueConicClientModule: RCTEventEmitter {
794
817
  - returns: An array of event names that may be published to the JavaScript.
795
818
  */
796
819
  override func supportedEvents() -> [String]! {
797
- return ["onBlueConicPluginLoad", "onBlueConicPluginDestroyed", "propertiesDialogueEvent"]
820
+ return ["onBlueConicPluginLoad", "onBlueConicPluginDestroyed", "propertiesDialogueEvent", "recommendationsDialogueEvent"]
798
821
  }
799
822
 
800
823
  /**
@@ -835,3 +858,22 @@ class PropertiesDialogueHandler: EventHandler {
835
858
  BlueConicClientModule.publishDialogueEvent(properties, eventName: self.eventName)
836
859
  }
837
860
  }
861
+
862
+ class RecommendationsDialogueHandler: EventHandler {
863
+ private let eventName: String
864
+
865
+ init(eventName: String) {
866
+ self.eventName = eventName
867
+ }
868
+
869
+ func handleEvent(_ event: BlueConicClient.Event) {
870
+ let recommendationsDialogueEvent = event as! RecommendationsDialogueEvent
871
+
872
+ var properties = [String: Any]()
873
+ properties["variantId"] = recommendationsDialogueEvent.variantId
874
+ properties["position"] = recommendationsDialogueEvent.position
875
+ properties["storeId"] = recommendationsDialogueEvent.storeId
876
+ properties["recommendations"] = recommendationsDialogueEvent.recommendations
877
+ BlueConicClientModule.publishDialogueEvent(properties, eventName: self.eventName)
878
+ }
879
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueconic/blueconic-react-native",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "The BlueConicClient Framework provides the basis for communicating with BlueConic.",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -26,8 +26,8 @@
26
26
  "author": "BlueConic (info@blueconic.com)",
27
27
  "license": "SEE LICENSE IN LICENSE",
28
28
  "nativeDependencies": {
29
- "android": "7.0.0",
30
- "ios": "5.0.0"
29
+ "android": "7.1.0",
30
+ "ios": "5.1.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react-native": "<1.0.0"