reactnative-plugin-appice 1.7.12 → 1.7.14
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/README.md +37 -37
- package/android/README.md +14 -14
- package/android/build.gradle +151 -151
- package/android/gitignore +47 -47
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -5
- package/android/gradlew +234 -234
- package/android/local.properties +8 -8
- package/android/src/main/AndroidManifest.xml +153 -153
- package/android/src/main/java/com/reactlibrary/AppICEUtils.java +241 -241
- package/android/src/main/java/com/reactlibrary/AppIceReactPluginModule.java +748 -748
- package/android/src/main/java/com/reactlibrary/AppIceReactPluginPackage.java +28 -28
- package/android/src/main/java/com/reactlibrary/CampaignCampsReceiver.java +56 -56
- package/android/src/main/java/com/reactlibrary/EnumConstants.java +256 -256
- package/android/src/main/java/com/reactlibrary/NotificationEventService.java +59 -59
- package/android/src/main/java/com/reactlibrary/StringConstants.java +9 -9
- package/example/App.js +292 -273
- package/example/Gemfile +6 -6
- package/example/__tests__/App-test.js +14 -14
- package/example/ancilliary.js +474 -327
- package/example/android/.gradle/7.3.3/checksums/checksums.lock +0 -0
- package/example/android/.gradle/7.3.3/fileChanges/last-build.bin +0 -0
- package/example/android/.gradle/7.3.3/fileHashes/fileHashes.lock +0 -0
- package/example/android/.gradle/7.3.3/gc.properties +0 -0
- package/example/android/.gradle/vcs-1/gc.properties +0 -0
- package/example/android/app/_BUCK +55 -55
- package/example/android/app/build.gradle +320 -322
- package/example/android/app/build_defs.bzl +19 -19
- package/example/android/app/proguard-rules.pro +10 -10
- package/example/android/app/src/debug/AndroidManifest.xml +13 -13
- package/example/android/app/src/debug/java/com/example/ReactNativeFlipper.java +73 -73
- package/example/android/app/src/main/AndroidManifest.xml +72 -72
- package/example/android/app/src/main/java/com/example/MainActivity.java +48 -48
- package/example/android/app/src/main/java/com/example/MainApplication.java +91 -95
- package/example/android/app/src/main/java/com/example/newarchitecture/MainApplicationReactNativeHost.java +116 -116
- package/example/android/app/src/main/java/com/example/newarchitecture/components/MainComponentsRegistry.java +36 -36
- package/example/android/app/src/main/java/com/example/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java +48 -48
- package/example/android/app/src/main/jni/Android.mk +48 -48
- package/example/android/app/src/main/jni/MainApplicationModuleProvider.cpp +24 -24
- package/example/android/app/src/main/jni/MainApplicationModuleProvider.h +16 -16
- package/example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp +45 -45
- package/example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h +38 -38
- package/example/android/app/src/main/jni/MainComponentsRegistry.cpp +61 -61
- package/example/android/app/src/main/jni/MainComponentsRegistry.h +32 -32
- package/example/android/app/src/main/jni/OnLoad.cpp +11 -11
- package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -36
- package/example/android/app/src/main/res/values/strings.xml +3 -3
- package/example/android/app/src/main/res/values/styles.xml +9 -9
- package/example/android/build.gradle +73 -73
- package/example/android/gradle/wrapper/gradle-wrapper.properties +5 -5
- package/example/android/gradle.properties +40 -40
- package/example/android/gradlew +234 -234
- package/example/android/settings.gradle +11 -11
- package/example/app.json +3 -3
- package/example/babel.config.js +3 -3
- package/example/index.js +9 -9
- package/example/ios/Podfile +44 -44
- package/example/ios/Podfile.lock +561 -561
- package/example/ios/_xcode.env +11 -11
- package/example/ios/example/AppDelegate.h +8 -8
- package/example/ios/example/AppDelegate.mm +174 -174
- package/example/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json +53 -53
- package/example/ios/example/Images.xcassets/Contents.json +6 -6
- package/example/ios/example/Info.plist +62 -62
- package/example/ios/example/LaunchScreen.storyboard +47 -47
- package/example/ios/example/example.entitlements +8 -8
- package/example/ios/example/main.m +10 -10
- package/example/ios/example.xcodeproj/project.pbxproj +712 -712
- package/example/ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme +88 -88
- package/example/ios/example.xcworkspace/contents.xcworkspacedata +10 -10
- package/example/ios/example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -8
- package/example/ios/exampleTests/Info.plist +24 -24
- package/example/ios/exampleTests/exampleTests.m +66 -66
- package/example/metro.config.js +17 -17
- package/example/package.json +36 -34
- package/example/yarn.lock +7176 -0
- package/index.js +485 -401
- package/ios/AppICEReactEvent.h +23 -23
- package/ios/AppICEReactEvent.m +86 -86
- package/ios/AppIceReactPlugin.h +59 -59
- package/ios/AppIceReactPlugin.m +641 -641
- package/ios/AppIceReactPlugin.xcodeproj/project.pbxproj +364 -364
- package/ios/AppIceReactPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -4
- package/ios/AppIceReactPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -8
- package/ios/AppIceReactPlugin.xcodeproj/xcuserdata/Adi.xcuserdatad/xcschemes/xcschememanagement.plist +14 -14
- package/ios/AppIceReactPlugin.xcodeproj/xcuserdata/artherajesh.xcuserdatad/xcschemes/xcschememanagement.plist +14 -14
- package/ios/AppIceReactPlugin.xcworkspace/contents.xcworkspacedata +10 -10
- package/ios/AppIceReactPlugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -8
- package/ios/AppIceReactPlugin.xcworkspace/xcuserdata/artherajesh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Podfile +10 -10
- package/ios/Podfile.lock +3 -3
- package/ios/Pods/Manifest.lock +3 -3
- package/ios/Pods/Pods.xcodeproj/project.pbxproj +395 -395
- package/ios/Pods/Pods.xcodeproj/xcuserdata/Adi.xcuserdatad/xcschemes/Pods-AppIceReactPlugin.xcscheme +58 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/Adi.xcuserdatad/xcschemes/xcschememanagement.plist +18 -18
- package/ios/Pods/Pods.xcodeproj/xcuserdata/artherajesh.xcuserdatad/xcschemes/xcschememanagement.plist +14 -14
- package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin-Info.plist +26 -26
- package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin-acknowledgements.markdown +3 -3
- package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin-acknowledgements.plist +29 -29
- package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin-dummy.m +5 -5
- package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin-umbrella.h +16 -16
- package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin.debug.xcconfig +6 -6
- package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin.modulemap +6 -6
- package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin.release.xcconfig +6 -6
- package/package.json +41 -40
- package/reactnative-plugin-appice.podspec +30 -30
- package/example/HelloWorldApp.js +0 -483
- package/example/android/app/google-services.json +0 -275
- package/example/android/local.properties +0 -8
- package/example/package-lock.json +0 -16722
package/index.js
CHANGED
|
@@ -1,401 +1,485 @@
|
|
|
1
|
-
import { DeviceEventEmitter, NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
|
-
import { Platform, Component } from 'react-native';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
eventEmitter = new NativeEventEmitter(NativeModules.
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
//========================
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
*
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
*
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
},
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
*
|
|
349
|
-
* @param
|
|
350
|
-
* @
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
1
|
+
import { DeviceEventEmitter, NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
|
+
import { Platform, Component } from 'react-native';
|
|
3
|
+
import { MMKV } from 'react-native-mmkv'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const AppIceReactPlugin = NativeModules.AppIceReactPlugin;
|
|
8
|
+
var eventEmitter;
|
|
9
|
+
if (Platform.OS === 'ios') {
|
|
10
|
+
eventEmitter = NativeModules.AppICEReactEvent ? new NativeEventEmitter(NativeModules.AppICEReactEvent) : DeviceEventEmitter;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
eventEmitter = new NativeEventEmitter(NativeModules.AppIceReactPlugin);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const appStorage = new MMKV({
|
|
17
|
+
id: 'AppICE-storage',
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const EVENT_KEY = "lastEvent"
|
|
21
|
+
const LAST_EVENT_KEY = "event_"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var AppICEReact = {
|
|
25
|
+
|
|
26
|
+
validateIntegration: AppIceReactPlugin.validateIntegration,
|
|
27
|
+
|
|
28
|
+
//========================
|
|
29
|
+
// PUSH
|
|
30
|
+
//========================
|
|
31
|
+
AppICEPushNotificationClicked: AppIceReactPlugin.AppICEPushNotificationClicked,
|
|
32
|
+
|
|
33
|
+
//==========================
|
|
34
|
+
// IN-APP
|
|
35
|
+
//==========================
|
|
36
|
+
AppICEInAppClicked: AppIceReactPlugin.AppICEInAppClicked,
|
|
37
|
+
|
|
38
|
+
//========================
|
|
39
|
+
// APP-INBOX
|
|
40
|
+
//========================
|
|
41
|
+
INBOX_MESSAGE: AppIceReactPlugin.INBOX_MESSAGE,
|
|
42
|
+
INBOX_TITLE: AppIceReactPlugin.INBOX_TITLE,
|
|
43
|
+
INBOX_MESSAGE_STATUS: AppIceReactPlugin.INBOX_MESSAGE_STATUS,
|
|
44
|
+
INBOX_CAMPAIGN_TYPE: AppIceReactPlugin.INBOX_CAMPAIGN_TYPE,
|
|
45
|
+
INBOX_MESSAGE_LANGUAGE: AppIceReactPlugin.INBOX_MESSAGE_LANGUAGE,
|
|
46
|
+
INBOX_MESSAGE_ID: AppIceReactPlugin.INBOX_MESSAGE_ID,
|
|
47
|
+
INBOX_CAMPAIGN_ID: AppIceReactPlugin.INBOX_CAMPAIGN_ID,
|
|
48
|
+
INBOX_MESSAGE_ICON: AppIceReactPlugin.INBOX_MESSAGE_ICON,
|
|
49
|
+
INBOX_CUSTOM_DATA: AppIceReactPlugin.INBOX_CUSTOM_DATA,
|
|
50
|
+
INBOX_MESSAGE_EXPANDED_IMAGE: AppIceReactPlugin.INBOX_MESSAGE_EXPANDED_IMAGE,
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
//=======================
|
|
54
|
+
// USER-PROFILE SETTING
|
|
55
|
+
//=======================
|
|
56
|
+
name: AppIceReactPlugin.APPICE_USER_NAME,
|
|
57
|
+
email: AppIceReactPlugin.APPICE_USER_EMAIL,
|
|
58
|
+
phone: AppIceReactPlugin.APPICE_USER_PHONE,
|
|
59
|
+
age: AppIceReactPlugin.APPICE_USER_AGE,
|
|
60
|
+
gender: AppIceReactPlugin.APPICE_USER_GENDER,
|
|
61
|
+
educationType: AppIceReactPlugin.APPICE_USER_EDUCATION_TYPE,
|
|
62
|
+
employmentType: AppIceReactPlugin.APPICE_USER_EMPLOYMENT_TYPE,
|
|
63
|
+
married: AppIceReactPlugin.APPICE_USER_MARRIED,
|
|
64
|
+
isEmployed: AppIceReactPlugin.APPICE_USER_IS_EMPLOYED,
|
|
65
|
+
dob: AppIceReactPlugin.APPICE_DATE_OF_BIRTH,
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
TOP_N_PRODUCTS_VIEWED: AppIceReactPlugin.TOP_N_PRODUCTS_VIEWED,
|
|
69
|
+
N_COMPLAINTS_RAISED: AppIceReactPlugin.N_COMPLAINTS_RAISED,
|
|
70
|
+
PREF_LOGIN_DEVICE: AppIceReactPlugin.PREF_LOGIN_DEVICE,
|
|
71
|
+
REFERRAL_CAMPAIGN: AppIceReactPlugin.REFERRAL_CAMPAIGN,
|
|
72
|
+
FIRST_SEEN: AppIceReactPlugin.FIRST_SEEN,
|
|
73
|
+
LAST_SEEN: AppIceReactPlugin.LAST_SEEN,
|
|
74
|
+
DEMOGRAPHIC_INFO: AppIceReactPlugin.DEMOGRAPHIC_INFO,
|
|
75
|
+
|
|
76
|
+
//================
|
|
77
|
+
// ECOMMERCE
|
|
78
|
+
//================
|
|
79
|
+
TOTAL_ORDER_VALUE: AppIceReactPlugin.TOTAL_ORDER_VALUE,
|
|
80
|
+
ADD_TO_CART_N_DAYS: AppIceReactPlugin.ADD_TO_CART_N_DAYS,
|
|
81
|
+
|
|
82
|
+
//====================
|
|
83
|
+
// FinancialServices
|
|
84
|
+
//====================
|
|
85
|
+
FINANCIAL_SERVICES: AppIceReactPlugin.FINANCIAL_SERVICES,
|
|
86
|
+
CREDIT_SCORE: AppIceReactPlugin.CREDIT_SCORE,
|
|
87
|
+
DEBT_TO_INCOME_RATIO: AppIceReactPlugin.DEBT_TO_INCOME_RATIO,
|
|
88
|
+
SAVINGS_BALANCE: AppIceReactPlugin.SAVINGS_BALANCE,
|
|
89
|
+
CHECKING_BALANCE: AppIceReactPlugin.CHECKING_BALANCE,
|
|
90
|
+
AVERAGE_TRANSACTION_AMOUNT: AppIceReactPlugin.AVERAGE_TRANSACTION_AMOUNT,
|
|
91
|
+
FREQUENCY_OF_TRANSACTION: AppIceReactPlugin.FREQUENCY_OF_TRANSACTION,
|
|
92
|
+
TYPE_OF_TRANSACTION: AppIceReactPlugin.TYPE_OF_TRANSACTION,
|
|
93
|
+
|
|
94
|
+
//======================
|
|
95
|
+
// LISTENER
|
|
96
|
+
//======================
|
|
97
|
+
/**
|
|
98
|
+
* add all of the registered listeners for given eventName.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} eventName - name of the event whose registered listeners to remove
|
|
101
|
+
* @param {callback} handler - handler for events
|
|
102
|
+
*/
|
|
103
|
+
addListener: function (eventName, handler) {
|
|
104
|
+
if (eventEmitter) {
|
|
105
|
+
eventEmitter.addListener(eventName, handler);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Removes all of the registered listeners for given eventName.
|
|
111
|
+
*
|
|
112
|
+
* @param {string} eventName - name of the event whose registered listeners to remove
|
|
113
|
+
*/
|
|
114
|
+
removeListener: function (eventName) {
|
|
115
|
+
if (eventEmitter) {
|
|
116
|
+
eventEmitter.removeAllListeners(eventName);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
//=========================
|
|
122
|
+
// SDK CONFIG
|
|
123
|
+
//========================
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* call this function before clearing old data from db/keychain
|
|
127
|
+
*/
|
|
128
|
+
preInitialise: function () {
|
|
129
|
+
this.getDeviceId((res) => {
|
|
130
|
+
if (res) {
|
|
131
|
+
this.setInternalId(res);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Meta data of the apps that is needed for sdk setting
|
|
138
|
+
* @param {string} appID - meta key
|
|
139
|
+
* @param {string} appKey - meta key
|
|
140
|
+
* @param {string} apiKey - meta key
|
|
141
|
+
* @param {string} deviceID - unique value to idetify the data from panel
|
|
142
|
+
* @param {string} region - e.i. US/GCC/IND
|
|
143
|
+
* @param {string} baseUrl -
|
|
144
|
+
* @param {object} certs - arrays of certificate paths
|
|
145
|
+
* startContext executes after getDeviceId callback
|
|
146
|
+
* if res exist assign the value of res else assign deviceID
|
|
147
|
+
*/
|
|
148
|
+
startContext: function (appID, appKey, apiKey, deviceID, region, baseUrl, certs) {
|
|
149
|
+
this.getDeviceId((res) => {
|
|
150
|
+
if (res) {
|
|
151
|
+
AppIceReactPlugin.startContext(appID, appKey, apiKey, res, region, baseUrl, certs)
|
|
152
|
+
} else {
|
|
153
|
+
AppIceReactPlugin.startContext(appID, appKey, apiKey, deviceID, region, baseUrl, certs)
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* call this function to register the lifeCycle state of the app
|
|
160
|
+
*/
|
|
161
|
+
registerLifeCycle: function () {
|
|
162
|
+
AppIceReactPlugin.registerLifeCycle();
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
//===========================
|
|
166
|
+
// EVENTS AND VARIABLES
|
|
167
|
+
//===========================
|
|
168
|
+
/**
|
|
169
|
+
* Record an event with optional event properties
|
|
170
|
+
* @param {string} eventName - the name of the event
|
|
171
|
+
* @param {object} props - the key-value properties of the event.
|
|
172
|
+
* @param {boolean} flush - to use caching feature.
|
|
173
|
+
* keys are strings and values can be string, number or boolean.
|
|
174
|
+
*/
|
|
175
|
+
tagEvent: async function (eventName, props, flush) {
|
|
176
|
+
console.log("tagEvent : eventName " + eventName + ", prop " + props + ", flush " + flush);
|
|
177
|
+
|
|
178
|
+
if (flush == undefined) {
|
|
179
|
+
await AppIceReactPlugin.tagEvent(eventName, props);
|
|
180
|
+
} else {
|
|
181
|
+
lastEventData = appStorage.getString(LAST_EVENT_KEY)
|
|
182
|
+
if (lastEventData != undefined && lastEventData !== eventName) {
|
|
183
|
+
try {
|
|
184
|
+
const storedEvents = appStorage.getString(EVENT_KEY + lastEventData);
|
|
185
|
+
console.log("tagEvent : storedEvents " + storedEvents);
|
|
186
|
+
|
|
187
|
+
if (storedEvents != null && storedEvents.length > 0) {
|
|
188
|
+
let events = storedEvents ? JSON.parse(storedEvents) : [];
|
|
189
|
+
|
|
190
|
+
const lastPropsData = events.reduce((acc, event) => {
|
|
191
|
+
return { ...acc, ...event.props };
|
|
192
|
+
}, {});
|
|
193
|
+
|
|
194
|
+
await AppIceReactPlugin.tagEvent(lastEventData, lastPropsData);
|
|
195
|
+
appStorage.delete(EVENT_KEY + lastEventData);
|
|
196
|
+
appStorage.delete(LAST_EVENT_KEY);
|
|
197
|
+
}
|
|
198
|
+
} catch (error) {
|
|
199
|
+
console.error('Failed to flush events:', error);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
await handleStoredEvents(eventName, props);
|
|
203
|
+
} else {
|
|
204
|
+
if (flush) {
|
|
205
|
+
await handleFlushEvent(eventName, props);
|
|
206
|
+
} else {
|
|
207
|
+
await handleStoredEvents(eventName, props);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* to store custom varibles like fcm token..
|
|
216
|
+
* @param {string} eventName - the name of the event
|
|
217
|
+
* @param {string} props - the name of the event
|
|
218
|
+
*/
|
|
219
|
+
setCustomVariable: function (eventName, props) {
|
|
220
|
+
AppIceReactPlugin.setCustomVariable(eventName, props);
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
//===========================
|
|
225
|
+
// CAMPAIGN SETTING
|
|
226
|
+
//===========================
|
|
227
|
+
/**
|
|
228
|
+
* Record an click event
|
|
229
|
+
* @param {string} eventName - the name of the event
|
|
230
|
+
*/
|
|
231
|
+
pushNotificationClicked: function (payload) {
|
|
232
|
+
AppIceReactPlugin.pushNotificationClicked(payload);
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
getCustomDataFromPayload: function (object) {
|
|
236
|
+
let userObj = JSON.parse(object, (key, value) => {
|
|
237
|
+
return value;
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
let map = new Map(Object.entries(userObj.cdata));
|
|
241
|
+
|
|
242
|
+
return map;
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
//=======================
|
|
246
|
+
// USER-PROFILE SETTING
|
|
247
|
+
//=======================
|
|
248
|
+
/**
|
|
249
|
+
* Set key-value properties on a user profile
|
|
250
|
+
* @param {object} profile - key-value profile properties. keys are strings and values can be string, number or boolean.
|
|
251
|
+
*/
|
|
252
|
+
setUser: function (profile) {
|
|
253
|
+
AppIceReactPlugin.setUser(profile);
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* get the properties of a user profile
|
|
258
|
+
* return JSONObject
|
|
259
|
+
*/
|
|
260
|
+
getUser: function (callback) {
|
|
261
|
+
callWithCallback('getUser', null, callback);
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
//===============================================
|
|
265
|
+
// User id setting
|
|
266
|
+
//===============================================
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Set unique user id
|
|
270
|
+
* @param {object} values - array of userids
|
|
271
|
+
*/
|
|
272
|
+
setUserId: function (values) {
|
|
273
|
+
AppIceReactPlugin.setUserId(values);
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Getuser id
|
|
278
|
+
* @param {object} values - array of userids
|
|
279
|
+
*/
|
|
280
|
+
getUserId: function (callback) {
|
|
281
|
+
callWithCallback('getUserId', null, callback);
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
//===============================================
|
|
285
|
+
// Device id setting
|
|
286
|
+
//===============================================
|
|
287
|
+
|
|
288
|
+
getDeviceId: function (callback) {
|
|
289
|
+
callWithCallback('getDeviceId', null, callback)
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
setInternalId: function (deviceId) {
|
|
293
|
+
AppIceReactPlugin.setInternalId(deviceId);
|
|
294
|
+
},
|
|
295
|
+
|
|
296
|
+
//===============================================
|
|
297
|
+
// AppInbox
|
|
298
|
+
//===============================================
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Get inbox messages list.
|
|
302
|
+
*
|
|
303
|
+
* @param type the message type
|
|
304
|
+
* 1 = ALL
|
|
305
|
+
* 2 = UNREAD
|
|
306
|
+
* 3 = READ
|
|
307
|
+
* 4 = VIEWED
|
|
308
|
+
* 5 = DELETED
|
|
309
|
+
* @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
|
|
310
|
+
* @callback will have the string json array
|
|
311
|
+
*/
|
|
312
|
+
getInboxMessages: function (type, userIds, callback) {
|
|
313
|
+
callWithCallback('getInboxMessages', [type, userIds], callback);
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Get inbox messages count.
|
|
319
|
+
*
|
|
320
|
+
* @param type the message type is integer
|
|
321
|
+
* 1 = ALL
|
|
322
|
+
* 2 = UNREAD
|
|
323
|
+
* 3 = READ
|
|
324
|
+
* 4 = VIEWED
|
|
325
|
+
* 5 = DELETED
|
|
326
|
+
* @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
|
|
327
|
+
* @callback will have the integer
|
|
328
|
+
*/
|
|
329
|
+
getMessageCount: function (type, userIds, callback) {
|
|
330
|
+
callWithCallback('getMessageCount', [type, userIds], callback);
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Get messages payload based on message id.
|
|
335
|
+
*
|
|
336
|
+
* @param messageId - message id of the notification
|
|
337
|
+
* @param userId - single userid in string ie. "useridA"
|
|
338
|
+
* @callback will have the json object
|
|
339
|
+
*/
|
|
340
|
+
getInboxMessageForId: function (messageId, userId, callback) {
|
|
341
|
+
callWithCallback('getInboxMessageForId', [messageId, userId], callback);
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* update message status ex. UNREAD to READ.
|
|
346
|
+
*
|
|
347
|
+
* @param messageId - message id of the notification
|
|
348
|
+
* @param type - integer value for status
|
|
349
|
+
* @param userId - single userid in string
|
|
350
|
+
* @callback will have the boolean
|
|
351
|
+
*/
|
|
352
|
+
updateInboxMessage: function (messageId, type, userId, callback) {
|
|
353
|
+
callWithCallback('updateInboxMessage', [messageId, type, userId], callback);
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
synchronizeInbox: function (timeout, callback) {
|
|
357
|
+
callWithCallback('synchronizeInbox', [timeout], callback)
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
//===============================================
|
|
361
|
+
// Rich Push AppInbox
|
|
362
|
+
//===============================================
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* getMediaData
|
|
366
|
+
* @param instanceInboxMessage - instance Dictionary
|
|
367
|
+
* @param values - NSString
|
|
368
|
+
* @callback will have the Dictionary
|
|
369
|
+
*/
|
|
370
|
+
|
|
371
|
+
getMediaData: function (instanceInboxMessage, mediaKey, callback) {
|
|
372
|
+
callWithCallback('getMediaData', [instanceInboxMessage, mediaKey], callback);
|
|
373
|
+
},
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* getMediaUrl
|
|
377
|
+
* @param instanceInboxMessage - instance Dictionary
|
|
378
|
+
* @param values - Dictionary
|
|
379
|
+
* @callback will have the string
|
|
380
|
+
*/
|
|
381
|
+
getMediaUrl: function (instanceInboxMessage, values, callback) {
|
|
382
|
+
callWithCallback('getMediaUrl', [instanceInboxMessage, values], callback);
|
|
383
|
+
},
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* getMediaType
|
|
387
|
+
* @param instanceInboxMessage - instance Dictionary
|
|
388
|
+
* @param values - Dictionary
|
|
389
|
+
* @callback will have the string
|
|
390
|
+
*/
|
|
391
|
+
getMediaType: function (instanceInboxMessage, values, callback) {
|
|
392
|
+
callWithCallback('getMediaType', [instanceInboxMessage, values], callback);
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* getMediaThumbnail
|
|
397
|
+
* @param instanceInboxMessage - instance Dictionary
|
|
398
|
+
* @param values - Dictionary
|
|
399
|
+
* @callback will have the string
|
|
400
|
+
*/
|
|
401
|
+
|
|
402
|
+
getMediaThumbnail: function (instanceInboxMessage, values, callback) {
|
|
403
|
+
callWithCallback('getMediaThumbnail', [instanceInboxMessage, values], callback);
|
|
404
|
+
},
|
|
405
|
+
|
|
406
|
+
/*==================
|
|
407
|
+
isDeviceReady
|
|
408
|
+
=====================*/
|
|
409
|
+
isDeviceReady: function (isActive) {
|
|
410
|
+
AppIceReactPlugin.isDeviceReady(isActive);
|
|
411
|
+
},
|
|
412
|
+
|
|
413
|
+
/*===============
|
|
414
|
+
synchronizeData
|
|
415
|
+
================*/
|
|
416
|
+
synchronizeData: function (timeout, callback) {
|
|
417
|
+
callWithCallback('synchronizeData', [timeout], callback)
|
|
418
|
+
},
|
|
419
|
+
|
|
420
|
+
/*===================
|
|
421
|
+
getUserForIds with userIds
|
|
422
|
+
=====================*/
|
|
423
|
+
|
|
424
|
+
getUserForIds: function (userIds, callback) {
|
|
425
|
+
callWithCallback('getUserForIds', [userIds], callback);
|
|
426
|
+
},
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
//================================
|
|
431
|
+
// INTERNAL COMMON APIS
|
|
432
|
+
//=================================
|
|
433
|
+
|
|
434
|
+
// internal function for callback
|
|
435
|
+
function callWithCallback(method, args, callback) {
|
|
436
|
+
if (typeof callback === 'undefined' || callback == null || typeof callback !== 'function') {
|
|
437
|
+
callback = (err, res) => {
|
|
438
|
+
defaultCallback(method, err, res);
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (args == null) {
|
|
443
|
+
args = [];
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
args.push(callback);
|
|
447
|
+
|
|
448
|
+
AppIceReactPlugin[method].apply(this, args);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
const handleStoredEvents = async (eventName, props) => {
|
|
452
|
+
try {
|
|
453
|
+
const storedEvents = appStorage.getString(EVENT_KEY + eventName);
|
|
454
|
+
let events = storedEvents ? JSON.parse(storedEvents) : [];
|
|
455
|
+
|
|
456
|
+
// Add the current event
|
|
457
|
+
events.push({ eventName, props });
|
|
458
|
+
|
|
459
|
+
// Save the updated events list
|
|
460
|
+
appStorage.set(EVENT_KEY + eventName, JSON.stringify(events));
|
|
461
|
+
appStorage.set(LAST_EVENT_KEY, eventName);
|
|
462
|
+
} catch (error) {
|
|
463
|
+
console.error('Failed to store event:', error);
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
const handleFlushEvent = async (eventName, props) => {
|
|
468
|
+
try {
|
|
469
|
+
const storedEvents = appStorage.getString(EVENT_KEY + eventName);
|
|
470
|
+
let events = storedEvents ? JSON.parse(storedEvents) : [];
|
|
471
|
+
|
|
472
|
+
events.forEach(event => {
|
|
473
|
+
Object.assign(props, event.props);
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
await AppIceReactPlugin.tagEvent(eventName, props);
|
|
477
|
+
|
|
478
|
+
appStorage.delete(EVENT_KEY + eventName);
|
|
479
|
+
appStorage.delete(LAST_EVENT_KEY);
|
|
480
|
+
} catch (error) {
|
|
481
|
+
console.error('Failed to flush events:', error);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
module.exports = AppICEReact;
|