reactnative-plugin-appice 1.7.8 → 1.7.9

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