@blueconic/blueconic-react-native 4.0.3 → 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.
- package/BlueConicReactNative.podspec +1 -1
- package/CHANGELOG.md +29 -0
- package/android/build.gradle +16 -12
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/blueconic/reactnative/BlueConicClientModule.java +190 -53
- package/android/src/test/java/com/blueconic/reactnative/BlueConicTests.kt +57 -21
- package/index.js +9 -1
- package/ios/BlueConicClient.xcodeproj/project.pbxproj +2 -2
- package/ios/BlueConicClientModule.m +11 -6
- package/ios/BlueConicClientModule.swift +95 -40
- package/package.json +3 -3
|
@@ -71,7 +71,7 @@ class BlueConicClientModuleTests {
|
|
|
71
71
|
val promise = mockk<Promise>(relaxed = true)
|
|
72
72
|
val expectedProfileId = "testProfileId"
|
|
73
73
|
|
|
74
|
-
every { blueConicClient.
|
|
74
|
+
every { blueConicClient.profile.id } returns expectedProfileId
|
|
75
75
|
|
|
76
76
|
// When
|
|
77
77
|
module.getProfileIdAsync(promise)
|
|
@@ -85,7 +85,7 @@ class BlueConicClientModuleTests {
|
|
|
85
85
|
// Given
|
|
86
86
|
val callback = mockk<Callback>(relaxed = true)
|
|
87
87
|
val expectedProfileId = "testProfileId"
|
|
88
|
-
every { blueConicClient.
|
|
88
|
+
every { blueConicClient.profile.id } returns expectedProfileId
|
|
89
89
|
|
|
90
90
|
// When
|
|
91
91
|
module.getProfileIdWithCallback(callback)
|
|
@@ -99,7 +99,7 @@ class BlueConicClientModuleTests {
|
|
|
99
99
|
// Given
|
|
100
100
|
val property = "testProperty"
|
|
101
101
|
val value = "testValue"
|
|
102
|
-
every { blueConicClient.
|
|
102
|
+
every { blueConicClient.profile.getValues(property) } returns listOf(value)
|
|
103
103
|
val expectedValue = MockWritableArray().apply { pushString(value) }
|
|
104
104
|
// When
|
|
105
105
|
module.getProfileValuesAsync(property, object : MockPromise() {
|
|
@@ -116,7 +116,7 @@ class BlueConicClientModuleTests {
|
|
|
116
116
|
// Given
|
|
117
117
|
val property = "testProperty"
|
|
118
118
|
val value = "testValue"
|
|
119
|
-
every { blueConicClient.
|
|
119
|
+
every { blueConicClient.profile.getValue(property) } returns value
|
|
120
120
|
val expectedValue = MockWritableArray().apply { pushString(value) }
|
|
121
121
|
// When
|
|
122
122
|
module.getProfileValueWithCallback(property, object : MockCallback() {
|
|
@@ -133,7 +133,7 @@ class BlueConicClientModuleTests {
|
|
|
133
133
|
// Given
|
|
134
134
|
val property = "testProperty"
|
|
135
135
|
val value = listOf("testValue1", "testValue2")
|
|
136
|
-
every { blueConicClient.
|
|
136
|
+
every { blueConicClient.profile.getValues(property) } returns value
|
|
137
137
|
val expectedValue = MockWritableArray().apply { pushArray(module.fromList(value)) }
|
|
138
138
|
// When
|
|
139
139
|
module.getProfileValuesAsync(property, object : MockPromise() {
|
|
@@ -151,7 +151,7 @@ class BlueConicClientModuleTests {
|
|
|
151
151
|
// Given
|
|
152
152
|
val property = "testProperty"
|
|
153
153
|
val value = listOf("testValue1", "testValue2")
|
|
154
|
-
every { blueConicClient.
|
|
154
|
+
every { blueConicClient.profile.getValues(property) } returns value
|
|
155
155
|
val expectedValue = MockWritableArray().apply { pushArray(module.fromList(value)) }
|
|
156
156
|
// When
|
|
157
157
|
module.getProfileValuesWithCallback(property, object : MockCallback() {
|
|
@@ -168,9 +168,9 @@ class BlueConicClientModuleTests {
|
|
|
168
168
|
// Given
|
|
169
169
|
val propertyNames = listOf("testProperty1", "testProperty2")
|
|
170
170
|
val propertyValue = listOf("testValue1", "testValue2")
|
|
171
|
-
every { blueConicClient.profilePropertyNames } returns propertyNames
|
|
172
|
-
every { blueConicClient.
|
|
173
|
-
every { blueConicClient.
|
|
171
|
+
every { blueConicClient.profile.profilePropertyNames } returns propertyNames
|
|
172
|
+
every { blueConicClient.profile.getValues(propertyNames[0]) } returns listOf(propertyValue[0])
|
|
173
|
+
every { blueConicClient.profile.getValues(propertyNames[1]) } returns listOf(propertyValue[1])
|
|
174
174
|
val expectedValue = MockWritableArray()
|
|
175
175
|
for (name in propertyNames) {
|
|
176
176
|
val valuesMap = MockWritableMap().apply {
|
|
@@ -198,7 +198,7 @@ class BlueConicClientModuleTests {
|
|
|
198
198
|
fun `getPrivacyLegislation should resolve promise with value`() {
|
|
199
199
|
// Given
|
|
200
200
|
val value = "GDPR"
|
|
201
|
-
every { blueConicClient.privacyLegislation } returns value
|
|
201
|
+
every { blueConicClient.profile.privacyLegislation } returns value
|
|
202
202
|
val expectedValue = MockWritableArray().apply { pushString(value) }
|
|
203
203
|
// When
|
|
204
204
|
module.getPrivacyLegislationAsync(object : MockPromise() {
|
|
@@ -214,7 +214,7 @@ class BlueConicClientModuleTests {
|
|
|
214
214
|
fun `getPrivacyLegislation should invoke callback with value`() {
|
|
215
215
|
// Given
|
|
216
216
|
val value = "GDPR"
|
|
217
|
-
every { blueConicClient.privacyLegislation } returns value
|
|
217
|
+
every { blueConicClient.profile.privacyLegislation } returns value
|
|
218
218
|
val expectedValue = MockWritableArray().apply { pushString(value) }
|
|
219
219
|
// When
|
|
220
220
|
module.getPrivacyLegislationWithCallback(object : MockCallback() {
|
|
@@ -229,7 +229,7 @@ class BlueConicClientModuleTests {
|
|
|
229
229
|
fun `getConsentedObjectives should resolve promise with value`() {
|
|
230
230
|
// Given
|
|
231
231
|
val value = listOf("tracking")
|
|
232
|
-
every { blueConicClient.consentedObjectives } returns value
|
|
232
|
+
every { blueConicClient.profile.consentedObjectives } returns value
|
|
233
233
|
val expectedValue = MockWritableArray().apply { pushArray(module.fromList(value)) }
|
|
234
234
|
// When
|
|
235
235
|
module.getConsentedObjectivesAsync(object : MockPromise() {
|
|
@@ -245,7 +245,7 @@ class BlueConicClientModuleTests {
|
|
|
245
245
|
fun `getConsentedObjectives should invoke callback with value`() {
|
|
246
246
|
// Given
|
|
247
247
|
val value = listOf("tracking")
|
|
248
|
-
every { blueConicClient.consentedObjectives } returns value
|
|
248
|
+
every { blueConicClient.profile.consentedObjectives } returns value
|
|
249
249
|
val expectedValue = MockWritableArray().apply { pushArray(module.fromList(value)) }
|
|
250
250
|
// When
|
|
251
251
|
module.getConsentedObjectivesWithCallback(object : MockCallback() {
|
|
@@ -260,7 +260,7 @@ class BlueConicClientModuleTests {
|
|
|
260
260
|
fun `getRefusedObjectives should resolve promise with value`() {
|
|
261
261
|
// Given
|
|
262
262
|
val value = listOf("analytics")
|
|
263
|
-
every { blueConicClient.refusedObjectives } returns value
|
|
263
|
+
every { blueConicClient.profile.refusedObjectives } returns value
|
|
264
264
|
val expectedValue = MockWritableArray().apply { pushArray(module.fromList(value)) }
|
|
265
265
|
// When
|
|
266
266
|
module.getRefusedObjectivesAsync(object : MockPromise() {
|
|
@@ -276,7 +276,7 @@ class BlueConicClientModuleTests {
|
|
|
276
276
|
fun `getRefusedObjectives should invoke callback with value`() {
|
|
277
277
|
// Given
|
|
278
278
|
val value = listOf("analytics")
|
|
279
|
-
every { blueConicClient.refusedObjectives } returns value
|
|
279
|
+
every { blueConicClient.profile.refusedObjectives } returns value
|
|
280
280
|
val expectedValue = MockWritableArray().apply { pushArray(module.fromList(value)) }
|
|
281
281
|
// When
|
|
282
282
|
module.getRefusedObjectivesWithCallback(object : MockCallback() {
|
|
@@ -363,7 +363,7 @@ class BlueConicClientModuleTests {
|
|
|
363
363
|
// When
|
|
364
364
|
module.addProfileValue(property, value)
|
|
365
365
|
// Then
|
|
366
|
-
verify { blueConicClient.
|
|
366
|
+
verify { blueConicClient.profile.addValue(property, value) }
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
@Test
|
|
@@ -374,7 +374,7 @@ class BlueConicClientModuleTests {
|
|
|
374
374
|
// When
|
|
375
375
|
module.addProfileValues(property, value)
|
|
376
376
|
// Then
|
|
377
|
-
verify { blueConicClient.
|
|
377
|
+
verify { blueConicClient.profile.addValues(property, any()) }
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
@Test
|
|
@@ -385,7 +385,7 @@ class BlueConicClientModuleTests {
|
|
|
385
385
|
// When
|
|
386
386
|
module.setProfileValue(property, value)
|
|
387
387
|
// Then
|
|
388
|
-
verify { blueConicClient.
|
|
388
|
+
verify { blueConicClient.profile.setValue(property, value) }
|
|
389
389
|
}
|
|
390
390
|
|
|
391
391
|
@Test
|
|
@@ -396,18 +396,18 @@ class BlueConicClientModuleTests {
|
|
|
396
396
|
// When
|
|
397
397
|
module.setProfileValues(property, value)
|
|
398
398
|
// Then
|
|
399
|
-
verify { blueConicClient.
|
|
399
|
+
verify { blueConicClient.profile.setValues(property, any()) }
|
|
400
400
|
}
|
|
401
401
|
|
|
402
402
|
@Test
|
|
403
403
|
fun `incrementProfileValue should increment value to profile`() {
|
|
404
404
|
// Given
|
|
405
405
|
val property = "testProperty"
|
|
406
|
-
val value =
|
|
406
|
+
val value = 1
|
|
407
407
|
// When
|
|
408
408
|
module.incrementProfileValue(property, value)
|
|
409
409
|
// Then
|
|
410
|
-
verify { blueConicClient.
|
|
410
|
+
verify { blueConicClient.profile.incrementValue(property, value) }
|
|
411
411
|
}
|
|
412
412
|
|
|
413
413
|
@Test
|
|
@@ -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
|
-
|
|
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 =
|
|
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 =
|
|
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(
|
|
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:(
|
|
40
|
+
RCT_EXTERN_METHOD(incrementProfileValue:(NSString *)property withValue:(int)value)
|
|
42
41
|
|
|
43
42
|
RCT_EXTERN_METHOD(setPrivacyLegislation:(NSString *)privacyLegislation)
|
|
44
43
|
|
|
@@ -61,6 +60,10 @@ RCT_EXTERN_METHOD(createEvent:(NSString *)eventName withProperties:(NSDictionary
|
|
|
61
60
|
RCT_EXTERN_METHOD(createEventAsync:(NSString *)eventName withProperties:(NSDictionary *)properties withResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
62
61
|
RCT_EXTERN_METHOD(createEventWithCallback:(NSString *)eventName withProperties:(NSDictionary *)properties withCallback:(RCTResponseSenderBlock)callback)
|
|
63
62
|
|
|
63
|
+
RCT_EXTERN_METHOD(createProfile:(RCTResponseSenderBlock)callback)
|
|
64
|
+
|
|
65
|
+
RCT_EXTERN_METHOD(deleteProfile:(RCTResponseSenderBlock)callback)
|
|
66
|
+
|
|
64
67
|
RCT_EXTERN_METHOD(updateProfile)
|
|
65
68
|
RCT_EXTERN_METHOD(updateProfileAsync:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
66
69
|
RCT_EXTERN_METHOD(updateProfileWithCallback:(RCTResponseSenderBlock)callback)
|
|
@@ -89,6 +92,10 @@ RCT_EXTERN_METHOD(createTimelineEventById:(NSString *)eventId withType:(NSString
|
|
|
89
92
|
RCT_EXTERN_METHOD(createTimelineEventByIdAsync:(NSString *)eventId withType:(NSString *)eventType withDate:(NSDate *)eventDate withProperties:(NSDictionary *)properties withResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
90
93
|
RCT_EXTERN_METHOD(createTimelineEventByIdWithCallback:(NSString *)eventId withType:(NSString *)eventType withDate:(NSDate *)eventDate withProperties:(NSDictionary *)properties withCallback:(RCTResponseSenderBlock)callback)
|
|
91
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
|
+
|
|
92
99
|
RCT_EXTERN_METHOD(subscribe:(NSString *)eventName withOnlyOnce:(BOOL)onlyOnce withIdentifier:(NSString *)identifier)
|
|
93
100
|
RCT_EXTERN_METHOD(unsubscribe:(NSString *)identifier)
|
|
94
101
|
|
|
@@ -103,8 +110,6 @@ RCT_EXTERN_METHOD(publishUpdateValuesEventWithCallback:(NSString *)selector with
|
|
|
103
110
|
RCT_EXTERN_METHOD(publishAdvancedEvent:(NSString *)name withValues:(NSArray *)values)
|
|
104
111
|
RCT_EXTERN_METHOD(publishAdvancedEventWithCallback:(NSString *)name withValues:(NSArray *)values withCallback:(RCTResponseSenderBlock)callback)
|
|
105
112
|
|
|
106
|
-
RCT_EXTERN_METHOD(clearProfileId:(RCTResponseSenderBlock)callback)
|
|
107
|
-
|
|
108
113
|
RCT_EXTERN_METHOD(getScreenNameAsync:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
109
114
|
RCT_EXTERN_METHOD(getScreenNameWithCallback:(RCTResponseSenderBlock)callback)
|
|
110
115
|
|
|
@@ -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 = "
|
|
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
|
|
|
@@ -64,7 +64,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
64
64
|
Native Modules to pass values back to the JavaScript.
|
|
65
65
|
*/
|
|
66
66
|
@objc func getProfileIdAsync(_ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void {
|
|
67
|
-
resolve([self.getBlueConicClientInstance().
|
|
67
|
+
resolve([self.getBlueConicClientInstance().getProfile().getId() ?? ""])
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -73,7 +73,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
73
73
|
Native Modules to pass values back to the JavaScript.
|
|
74
74
|
*/
|
|
75
75
|
@objc func getProfileIdWithCallback(_ callback: RCTResponseSenderBlock) -> Void {
|
|
76
|
-
callback([self.getBlueConicClientInstance().
|
|
76
|
+
callback([self.getBlueConicClientInstance().getProfile().getId() ?? ""])
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
@@ -84,7 +84,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
84
84
|
Native Modules to pass values back to the JavaScript.
|
|
85
85
|
*/
|
|
86
86
|
@objc func getProfileValueAsync(_ property: String, withResolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void {
|
|
87
|
-
resolve([self.getBlueConicClientInstance().
|
|
87
|
+
resolve([self.getBlueConicClientInstance().getProfile().getValue(property)])
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
|
|
@@ -96,7 +96,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
96
96
|
Native Modules to pass values back to the JavaScript.
|
|
97
97
|
*/
|
|
98
98
|
@objc func getProfileValuesAsync(_ property: String, withResolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void {
|
|
99
|
-
resolve(self.getBlueConicClientInstance().
|
|
99
|
+
resolve(self.getBlueConicClientInstance().getProfile().getValues(property))
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/**
|
|
@@ -107,7 +107,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
107
107
|
Native Modules to pass values back to the JavaScript.
|
|
108
108
|
*/
|
|
109
109
|
@objc func getProfileValueWithCallback(_ property: String, withCallback callback: RCTResponseSenderBlock) -> Void {
|
|
110
|
-
callback([self.getBlueConicClientInstance().
|
|
110
|
+
callback([self.getBlueConicClientInstance().getProfile().getValue(property)])
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
|
|
@@ -119,7 +119,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
119
119
|
Native Modules to pass values back to the JavaScript.
|
|
120
120
|
*/
|
|
121
121
|
@objc func getProfileValuesWithCallback(_ property: String, withCallback callback: RCTResponseSenderBlock) -> Void {
|
|
122
|
-
callback(self.getBlueConicClientInstance().
|
|
122
|
+
callback(self.getBlueConicClientInstance().getProfile().getValues(property))
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/**
|
|
@@ -128,7 +128,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
128
128
|
*/
|
|
129
129
|
@objc func getAllProfilePropertiesAsync(_ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void {
|
|
130
130
|
var result = [[String: String]]()
|
|
131
|
-
let allProperties = self.getBlueConicClientInstance().
|
|
131
|
+
let allProperties = self.getBlueConicClientInstance().getProfile().getAllProperties()
|
|
132
132
|
for (key, value) in allProperties {
|
|
133
133
|
let item = [
|
|
134
134
|
"id": key,
|
|
@@ -145,7 +145,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
145
145
|
Native Modules to pass values back to the JavaScript.
|
|
146
146
|
*/
|
|
147
147
|
@objc func getPrivacyLegislationAsync(_ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void {
|
|
148
|
-
resolve([self.getBlueConicClientInstance().getPrivacyLegislation() ?? ""])
|
|
148
|
+
resolve([self.getBlueConicClientInstance().getProfile().getPrivacyLegislation() ?? ""])
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
/**
|
|
@@ -154,7 +154,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
154
154
|
Native Modules to pass values back to the JavaScript.
|
|
155
155
|
*/
|
|
156
156
|
@objc func getPrivacyLegislationWithCallback(_ callback: RCTResponseSenderBlock) -> Void {
|
|
157
|
-
callback([self.getBlueConicClientInstance().getPrivacyLegislation() ?? ""])
|
|
157
|
+
callback([self.getBlueConicClientInstance().getProfile().getPrivacyLegislation() ?? ""])
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
@@ -163,7 +163,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
163
163
|
Native Modules to pass values back to the JavaScript.
|
|
164
164
|
*/
|
|
165
165
|
@objc func getConsentedObjectivesAsync(_ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void {
|
|
166
|
-
resolve(self.getBlueConicClientInstance().getConsentedObjectives())
|
|
166
|
+
resolve(self.getBlueConicClientInstance().getProfile().getConsentedObjectives())
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
/**
|
|
@@ -172,7 +172,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
172
172
|
Native Modules to pass values back to the JavaScript.
|
|
173
173
|
*/
|
|
174
174
|
@objc func getConsentedObjectivesWithCallback(_ callback: RCTResponseSenderBlock) -> Void {
|
|
175
|
-
callback(self.getBlueConicClientInstance().getConsentedObjectives())
|
|
175
|
+
callback(self.getBlueConicClientInstance().getProfile().getConsentedObjectives())
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
/**
|
|
@@ -181,7 +181,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
181
181
|
Native Modules to pass values back to the JavaScript.
|
|
182
182
|
*/
|
|
183
183
|
@objc func getRefusedObjectivesAsync(_ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) -> Void {
|
|
184
|
-
resolve(self.getBlueConicClientInstance().getRefusedObjectives())
|
|
184
|
+
resolve(self.getBlueConicClientInstance().getProfile().getRefusedObjectives())
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
/**
|
|
@@ -190,7 +190,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
190
190
|
Native Modules to pass values back to the JavaScript.
|
|
191
191
|
*/
|
|
192
192
|
@objc func getRefusedObjectivesWithCallback(_ callback: RCTResponseSenderBlock) -> Void {
|
|
193
|
-
callback(self.getBlueConicClientInstance().getRefusedObjectives())
|
|
193
|
+
callback(self.getBlueConicClientInstance().getProfile().getRefusedObjectives())
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
/**
|
|
@@ -221,7 +221,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
221
221
|
- parameter values: An Array containing Strings to be added to the profile property.
|
|
222
222
|
*/
|
|
223
223
|
@objc func addProfileValue(_ property: String, withValue value: String) -> Void {
|
|
224
|
-
self.getBlueConicClientInstance().
|
|
224
|
+
self.getBlueConicClientInstance().getProfile().addValue(property, value: value)
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
/**
|
|
@@ -230,7 +230,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
230
230
|
- parameter values: An Array containing Strings to be added to the profile property.
|
|
231
231
|
*/
|
|
232
232
|
@objc func addProfileValues(_ property: String, withValues values: [String]) -> Void {
|
|
233
|
-
self.getBlueConicClientInstance().
|
|
233
|
+
self.getBlueConicClientInstance().getProfile().addValues(property, values: values)
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
/**
|
|
@@ -238,7 +238,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
238
238
|
- parameter objectiveId: The ID of the objective to add to consented objectives.
|
|
239
239
|
*/
|
|
240
240
|
@objc func addConsentedObjective(_ objectiveId: String) -> Void {
|
|
241
|
-
self.getBlueConicClientInstance().addConsentedObjective(objectiveId)
|
|
241
|
+
self.getBlueConicClientInstance().getProfile().addConsentedObjective(objectiveId)
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
/**
|
|
@@ -246,7 +246,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
246
246
|
- parameter objectiveId: The ID of the objective to add to refused objectives.
|
|
247
247
|
*/
|
|
248
248
|
@objc func addRefusedObjective(_ objectiveId: String) -> Void {
|
|
249
|
-
self.getBlueConicClientInstance().addRefusedObjective(objectiveId)
|
|
249
|
+
self.getBlueConicClientInstance().getProfile().addRefusedObjective(objectiveId)
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
// MARK: SETTERS
|
|
@@ -256,7 +256,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
256
256
|
- parameter values: An Array containing Strings to be set as the new values for the profile property.
|
|
257
257
|
*/
|
|
258
258
|
@objc func setProfileValue(_ property: String, withValue value: String) -> Void {
|
|
259
|
-
self.getBlueConicClientInstance().
|
|
259
|
+
self.getBlueConicClientInstance().getProfile().setValue(property, value: value)
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
/**
|
|
@@ -265,7 +265,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
265
265
|
- parameter values: An Array containing Strings to be set as the new values for the profile property.
|
|
266
266
|
*/
|
|
267
267
|
@objc func setProfileValues(_ property: String, withValues values: [String]) -> Void {
|
|
268
|
-
self.getBlueConicClientInstance().
|
|
268
|
+
self.getBlueConicClientInstance().getProfile().setValues(property, values: values)
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
// MARK: INCREMENT
|
|
@@ -274,8 +274,8 @@ 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:
|
|
278
|
-
self.getBlueConicClientInstance().
|
|
277
|
+
@objc func incrementProfileValue(_ property: String, withValue value: Int) -> Void {
|
|
278
|
+
self.getBlueConicClientInstance().getProfile().incrementValue(property, value: value)
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
/**
|
|
@@ -283,7 +283,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
283
283
|
- parameter privacyLegislation: The privacy legislation.
|
|
284
284
|
*/
|
|
285
285
|
@objc func setPrivacyLegislation(_ privacyLegislation: String) -> Void {
|
|
286
|
-
self.getBlueConicClientInstance().setPrivacyLegislation(privacyLegislation)
|
|
286
|
+
self.getBlueConicClientInstance().getProfile().setPrivacyLegislation(privacyLegislation)
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
/**
|
|
@@ -291,7 +291,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
291
291
|
- parameter objectiveIds: An Array containing Strings to be set as the new objective IDs for the consented objectives list.
|
|
292
292
|
*/
|
|
293
293
|
@objc func setConsentedObjectives(_ objectiveIds: [String]) -> Void {
|
|
294
|
-
self.getBlueConicClientInstance().setConsentedObjectives(objectiveIds)
|
|
294
|
+
self.getBlueConicClientInstance().getProfile().setConsentedObjectives(objectiveIds)
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
/**
|
|
@@ -299,7 +299,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
299
299
|
- parameter objectiveIds: An Array containing Strings to be set as the new objective IDs for the consented objectives list.
|
|
300
300
|
*/
|
|
301
301
|
@objc func setRefusedObjectives(_ objectiveIds: [String]) -> Void {
|
|
302
|
-
self.getBlueConicClientInstance().setRefusedObjectives(objectiveIds)
|
|
302
|
+
self.getBlueConicClientInstance().getProfile().setRefusedObjectives(objectiveIds)
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
// MARK: PUBLIC BLUECONIC FUNCTIONS
|
|
@@ -327,6 +327,32 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
327
327
|
}
|
|
328
328
|
})
|
|
329
329
|
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
Clears the profile ID from the BlueConic client locally (cache). A new profile ID will be generated.
|
|
333
|
+
*/
|
|
334
|
+
@objc func createProfile(_ callback: @escaping RCTResponseSenderBlock) -> Void {
|
|
335
|
+
self.getBlueConicClientInstance().createProfile { result in
|
|
336
|
+
if result.success {
|
|
337
|
+
callback([true, nil])
|
|
338
|
+
} else if let error = result.error {
|
|
339
|
+
callback([false, error.nsError.localizedDescription])
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
Removes the profile from the BlueConic servers. The profile ID will be removed from the BlueConic client. A new profile ID will be generated.
|
|
346
|
+
*/
|
|
347
|
+
@objc func deleteProfile(_ callback: @escaping RCTResponseSenderBlock) -> Void {
|
|
348
|
+
self.getBlueConicClientInstance().deleteProfile { result in
|
|
349
|
+
if result.success {
|
|
350
|
+
callback([true, nil])
|
|
351
|
+
} else if let error = result.error {
|
|
352
|
+
callback([false, error.nsError.localizedDescription])
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
330
356
|
|
|
331
357
|
/**
|
|
332
358
|
Calls the updateProfile method of the BlueConicClient to sync/ update the profile properties from the Mobile app with the BlueConic server.
|
|
@@ -545,18 +571,41 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
545
571
|
})
|
|
546
572
|
}
|
|
547
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
|
+
|
|
548
595
|
@objc func subscribe(_ eventName: String, withOnlyOnce onlyOnce: Bool, withIdentifier identifier: String) -> Void {
|
|
549
596
|
let eventHandler: EventHandler
|
|
550
597
|
|
|
551
598
|
switch eventName {
|
|
552
599
|
case "propertiesDialogueEvent":
|
|
553
600
|
eventHandler = PropertiesDialogueHandler(eventName: eventName)
|
|
601
|
+
case "recommendationsDialogueEvent":
|
|
602
|
+
eventHandler = RecommendationsDialogueHandler(eventName: eventName)
|
|
554
603
|
default:
|
|
555
604
|
eventHandler = DefaultEventHandler()
|
|
556
605
|
}
|
|
557
606
|
|
|
558
607
|
self.getBlueConicClientInstance().getEventManager().subscribe(
|
|
559
|
-
|
|
608
|
+
eventName,
|
|
560
609
|
callbackObject: eventHandler,
|
|
561
610
|
onlyOnce: onlyOnce,
|
|
562
611
|
identifier: identifier
|
|
@@ -692,19 +741,6 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
692
741
|
|
|
693
742
|
}
|
|
694
743
|
|
|
695
|
-
/**
|
|
696
|
-
Resets the BlueConic profile id. This will generate a new profile id for the current user.
|
|
697
|
-
*/
|
|
698
|
-
@objc func clearProfileId(_ callback: @escaping RCTResponseSenderBlock) -> Void {
|
|
699
|
-
self.getBlueConicClientInstance().clearProfileId { result in
|
|
700
|
-
if result.success {
|
|
701
|
-
callback([true, nil])
|
|
702
|
-
} else if let error = result.error {
|
|
703
|
-
callback([false, error.nsError.localizedDescription])
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
|
|
708
744
|
/**
|
|
709
745
|
Returns the current screen name.
|
|
710
746
|
- parameter promise: The promise to handle the obtained value. Promises are necessary in Native Modules
|
|
@@ -781,7 +817,7 @@ class BlueConicClientModule: RCTEventEmitter {
|
|
|
781
817
|
- returns: An array of event names that may be published to the JavaScript.
|
|
782
818
|
*/
|
|
783
819
|
override func supportedEvents() -> [String]! {
|
|
784
|
-
return ["onBlueConicPluginLoad", "onBlueConicPluginDestroyed", "propertiesDialogueEvent"]
|
|
820
|
+
return ["onBlueConicPluginLoad", "onBlueConicPluginDestroyed", "propertiesDialogueEvent", "recommendationsDialogueEvent"]
|
|
785
821
|
}
|
|
786
822
|
|
|
787
823
|
/**
|
|
@@ -822,3 +858,22 @@ class PropertiesDialogueHandler: EventHandler {
|
|
|
822
858
|
BlueConicClientModule.publishDialogueEvent(properties, eventName: self.eventName)
|
|
823
859
|
}
|
|
824
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": "
|
|
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": "
|
|
30
|
-
"ios": "
|
|
29
|
+
"android": "7.1.0",
|
|
30
|
+
"ios": "5.1.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react-native": "<1.0.0"
|