reactnative-plugin-appice 1.7.13 → 1.7.15
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/android/src/main/test +0 -0
- package/example/App.js +11 -2
- package/example/ancilliary.js +150 -3
- package/example/android/gradlew +0 -0
- package/example/android/local.properties +1 -1
- package/example/package.json +3 -1
- package/example/yarn.lock +6736 -6199
- package/index.js +145 -26
- package/ios/AppIceReactPlugin.m +1 -1
- package/ios/AppIceReactPlugin.xcworkspace/xcuserdata/artherajesh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/package.json +3 -2
package/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DeviceEventEmitter, NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
2
|
import { Platform, Component } from 'react-native';
|
|
3
|
+
// import { MMKV } from 'react-native-mmkv'
|
|
4
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
3
5
|
|
|
4
6
|
const AppIceReactPlugin = NativeModules.AppIceReactPlugin;
|
|
5
7
|
var eventEmitter;
|
|
@@ -9,6 +11,15 @@ if (Platform.OS === 'ios') {
|
|
|
9
11
|
else {
|
|
10
12
|
eventEmitter = new NativeEventEmitter(NativeModules.AppIceReactPlugin);
|
|
11
13
|
}
|
|
14
|
+
|
|
15
|
+
// export const appStorage = new MMKV({
|
|
16
|
+
// id: 'AppICE-storage',
|
|
17
|
+
// })
|
|
18
|
+
|
|
19
|
+
const EVENT_KEY = "lastEvent"
|
|
20
|
+
const LAST_EVENT_KEY = "event_"
|
|
21
|
+
|
|
22
|
+
|
|
12
23
|
var AppICEReact = {
|
|
13
24
|
|
|
14
25
|
validateIntegration: AppIceReactPlugin.validateIntegration,
|
|
@@ -50,7 +61,7 @@ var AppICEReact = {
|
|
|
50
61
|
employmentType: AppIceReactPlugin.APPICE_USER_EMPLOYMENT_TYPE,
|
|
51
62
|
married: AppIceReactPlugin.APPICE_USER_MARRIED,
|
|
52
63
|
isEmployed: AppIceReactPlugin.APPICE_USER_IS_EMPLOYED,
|
|
53
|
-
dob:AppIceReactPlugin.APPICE_DATE_OF_BIRTH,
|
|
64
|
+
dob: AppIceReactPlugin.APPICE_DATE_OF_BIRTH,
|
|
54
65
|
|
|
55
66
|
|
|
56
67
|
TOP_N_PRODUCTS_VIEWED: AppIceReactPlugin.TOP_N_PRODUCTS_VIEWED,
|
|
@@ -127,10 +138,10 @@ var AppICEReact = {
|
|
|
127
138
|
* @param {string} appKey - meta key
|
|
128
139
|
* @param {string} apiKey - meta key
|
|
129
140
|
* @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
|
|
141
|
+
* @param {string} region - e.i. US/GCC/IND
|
|
142
|
+
* @param {string} baseUrl -
|
|
143
|
+
* @param {object} certs - arrays of certificate paths
|
|
144
|
+
* startContext executes after getDeviceId callback
|
|
134
145
|
* if res exist assign the value of res else assign deviceID
|
|
135
146
|
*/
|
|
136
147
|
startContext: function (appID, appKey, apiKey, deviceID, region, baseUrl, certs) {
|
|
@@ -157,12 +168,53 @@ var AppICEReact = {
|
|
|
157
168
|
* Record an event with optional event properties
|
|
158
169
|
* @param {string} eventName - the name of the event
|
|
159
170
|
* @param {object} props - the key-value properties of the event.
|
|
171
|
+
* @param {boolean} flush - to use caching feature.
|
|
160
172
|
* keys are strings and values can be string, number or boolean.
|
|
161
173
|
*/
|
|
162
|
-
tagEvent: function (eventName, props) {
|
|
163
|
-
|
|
174
|
+
tagEvent: async function (eventName, props, flush) {
|
|
175
|
+
console.log("tagEvent : eventName " + eventName + ", prop " + props + ", flush " + flush);
|
|
176
|
+
|
|
177
|
+
if (flush == undefined || flush == null) {
|
|
178
|
+
await AppIceReactPlugin.tagEvent(eventName, props);
|
|
179
|
+
} else {
|
|
180
|
+
const lastEventData = await getEventData(LAST_EVENT_KEY)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
if (lastEventData != undefined && lastEventData !== eventName) {
|
|
184
|
+
try {
|
|
185
|
+
const storedEvents = await getEventData(EVENT_KEY + lastEventData)
|
|
186
|
+
|
|
187
|
+
console.log("tagEvent : storedEvents " + storedEvents);
|
|
188
|
+
|
|
189
|
+
if (storedEvents != null && storedEvents.length > 0) {
|
|
190
|
+
let events = storedEvents ? JSON.parse(storedEvents) : [];
|
|
191
|
+
|
|
192
|
+
const lastPropsData = events.reduce((acc, event) => {
|
|
193
|
+
return { ...acc, ...event.props };
|
|
194
|
+
}, {});
|
|
195
|
+
|
|
196
|
+
await AppIceReactPlugin.tagEvent(lastEventData, lastPropsData);
|
|
197
|
+
|
|
198
|
+
await deleteData(EVENT_KEY + lastEventData)
|
|
199
|
+
await deleteData(LAST_EVENT_KEY)
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
} catch (error) {
|
|
203
|
+
console.error('Failed to flush events:', error);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
await handleStoredEvents(eventName, props);
|
|
207
|
+
} else {
|
|
208
|
+
if (flush) {
|
|
209
|
+
await handleFlushEvent(eventName, props);
|
|
210
|
+
} else {
|
|
211
|
+
await handleStoredEvents(eventName, props);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
164
215
|
},
|
|
165
216
|
|
|
217
|
+
|
|
166
218
|
/**
|
|
167
219
|
* to store custom varibles like fcm token..
|
|
168
220
|
* @param {string} eventName - the name of the event
|
|
@@ -218,7 +270,7 @@ var AppICEReact = {
|
|
|
218
270
|
//===============================================
|
|
219
271
|
|
|
220
272
|
/**
|
|
221
|
-
* Set unique user id
|
|
273
|
+
* Set unique user id
|
|
222
274
|
* @param {object} values - array of userids
|
|
223
275
|
*/
|
|
224
276
|
setUserId: function (values) {
|
|
@@ -226,7 +278,7 @@ var AppICEReact = {
|
|
|
226
278
|
},
|
|
227
279
|
|
|
228
280
|
/**
|
|
229
|
-
* Getuser id
|
|
281
|
+
* Getuser id
|
|
230
282
|
* @param {object} values - array of userids
|
|
231
283
|
*/
|
|
232
284
|
getUserId: function (callback) {
|
|
@@ -259,7 +311,7 @@ var AppICEReact = {
|
|
|
259
311
|
* 4 = VIEWED
|
|
260
312
|
* 5 = DELETED
|
|
261
313
|
* @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
|
|
314
|
+
* @callback will have the string json array
|
|
263
315
|
*/
|
|
264
316
|
getInboxMessages: function (type, userIds, callback) {
|
|
265
317
|
callWithCallback('getInboxMessages', [type, userIds], callback);
|
|
@@ -276,7 +328,7 @@ var AppICEReact = {
|
|
|
276
328
|
* 4 = VIEWED
|
|
277
329
|
* 5 = DELETED
|
|
278
330
|
* @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
|
|
331
|
+
* @callback will have the integer
|
|
280
332
|
*/
|
|
281
333
|
getMessageCount: function (type, userIds, callback) {
|
|
282
334
|
callWithCallback('getMessageCount', [type, userIds], callback);
|
|
@@ -287,7 +339,7 @@ var AppICEReact = {
|
|
|
287
339
|
*
|
|
288
340
|
* @param messageId - message id of the notification
|
|
289
341
|
* @param userId - single userid in string ie. "useridA"
|
|
290
|
-
* @callback will have the json object
|
|
342
|
+
* @callback will have the json object
|
|
291
343
|
*/
|
|
292
344
|
getInboxMessageForId: function (messageId, userId, callback) {
|
|
293
345
|
callWithCallback('getInboxMessageForId', [messageId, userId], callback);
|
|
@@ -298,8 +350,8 @@ var AppICEReact = {
|
|
|
298
350
|
*
|
|
299
351
|
* @param messageId - message id of the notification
|
|
300
352
|
* @param type - integer value for status
|
|
301
|
-
* @param userId - single userid in string
|
|
302
|
-
* @callback will have the boolean
|
|
353
|
+
* @param userId - single userid in string
|
|
354
|
+
* @callback will have the boolean
|
|
303
355
|
*/
|
|
304
356
|
updateInboxMessage: function (messageId, type, userId, callback) {
|
|
305
357
|
callWithCallback('updateInboxMessage', [messageId, type, userId], callback);
|
|
@@ -310,25 +362,25 @@ var AppICEReact = {
|
|
|
310
362
|
},
|
|
311
363
|
|
|
312
364
|
//===============================================
|
|
313
|
-
// Rich Push AppInbox
|
|
365
|
+
// Rich Push AppInbox
|
|
314
366
|
//===============================================
|
|
315
367
|
|
|
316
368
|
/**
|
|
317
369
|
* getMediaData
|
|
318
370
|
* @param instanceInboxMessage - instance Dictionary
|
|
319
371
|
* @param values - NSString
|
|
320
|
-
* @callback will have the Dictionary
|
|
372
|
+
* @callback will have the Dictionary
|
|
321
373
|
*/
|
|
322
374
|
|
|
323
375
|
getMediaData: function (instanceInboxMessage, mediaKey, callback) {
|
|
324
376
|
callWithCallback('getMediaData', [instanceInboxMessage, mediaKey], callback);
|
|
325
|
-
|
|
377
|
+
},
|
|
326
378
|
|
|
327
379
|
/**
|
|
328
380
|
* getMediaUrl
|
|
329
381
|
* @param instanceInboxMessage - instance Dictionary
|
|
330
382
|
* @param values - Dictionary
|
|
331
|
-
* @callback will have the string
|
|
383
|
+
* @callback will have the string
|
|
332
384
|
*/
|
|
333
385
|
getMediaUrl: function (instanceInboxMessage, values, callback) {
|
|
334
386
|
callWithCallback('getMediaUrl', [instanceInboxMessage, values], callback);
|
|
@@ -338,38 +390,38 @@ var AppICEReact = {
|
|
|
338
390
|
* getMediaType
|
|
339
391
|
* @param instanceInboxMessage - instance Dictionary
|
|
340
392
|
* @param values - Dictionary
|
|
341
|
-
* @callback will have the string
|
|
393
|
+
* @callback will have the string
|
|
342
394
|
*/
|
|
343
395
|
getMediaType: function (instanceInboxMessage, values, callback) {
|
|
344
396
|
callWithCallback('getMediaType', [instanceInboxMessage, values], callback);
|
|
345
397
|
},
|
|
346
|
-
|
|
398
|
+
|
|
347
399
|
/**
|
|
348
400
|
* getMediaThumbnail
|
|
349
401
|
* @param instanceInboxMessage - instance Dictionary
|
|
350
402
|
* @param values - Dictionary
|
|
351
|
-
* @callback will have the string
|
|
403
|
+
* @callback will have the string
|
|
352
404
|
*/
|
|
353
405
|
|
|
354
406
|
getMediaThumbnail: function (instanceInboxMessage, values, callback) {
|
|
355
|
-
callWithCallback('getMediaThumbnail', [instanceInboxMessage, values],callback);
|
|
407
|
+
callWithCallback('getMediaThumbnail', [instanceInboxMessage, values], callback);
|
|
356
408
|
},
|
|
357
409
|
|
|
358
410
|
/*==================
|
|
359
411
|
isDeviceReady
|
|
360
412
|
=====================*/
|
|
361
|
-
isDeviceReady: function(isActive) {
|
|
362
|
-
|
|
413
|
+
isDeviceReady: function (isActive) {
|
|
414
|
+
AppIceReactPlugin.isDeviceReady(isActive);
|
|
363
415
|
},
|
|
364
416
|
|
|
365
417
|
/*===============
|
|
366
418
|
synchronizeData
|
|
367
419
|
================*/
|
|
368
420
|
synchronizeData: function (timeout, callback) {
|
|
369
|
-
callWithCallback('synchronizeData',[timeout],callback)
|
|
421
|
+
callWithCallback('synchronizeData', [timeout], callback)
|
|
370
422
|
},
|
|
371
423
|
|
|
372
|
-
|
|
424
|
+
/*===================
|
|
373
425
|
getUserForIds with userIds
|
|
374
426
|
=====================*/
|
|
375
427
|
|
|
@@ -377,9 +429,12 @@ var AppICEReact = {
|
|
|
377
429
|
callWithCallback('getUserForIds', [userIds], callback);
|
|
378
430
|
},
|
|
379
431
|
};
|
|
432
|
+
|
|
433
|
+
|
|
380
434
|
//================================
|
|
381
435
|
// INTERNAL COMMON APIS
|
|
382
436
|
//=================================
|
|
437
|
+
|
|
383
438
|
// internal function for callback
|
|
384
439
|
function callWithCallback(method, args, callback) {
|
|
385
440
|
if (typeof callback === 'undefined' || callback == null || typeof callback !== 'function') {
|
|
@@ -397,5 +452,69 @@ function callWithCallback(method, args, callback) {
|
|
|
397
452
|
AppIceReactPlugin[method].apply(this, args);
|
|
398
453
|
}
|
|
399
454
|
|
|
455
|
+
const handleStoredEvents = async (eventName, props) => {
|
|
456
|
+
try {
|
|
457
|
+
const storedEvents = await getEventData(EVENT_KEY + eventName);
|
|
458
|
+
let events = storedEvents ? JSON.parse(storedEvents) : [];
|
|
459
|
+
|
|
460
|
+
// Add the current event
|
|
461
|
+
events.push({ eventName, props });
|
|
462
|
+
|
|
463
|
+
// Save the updated events list
|
|
464
|
+
// appStorage.set(EVENT_KEY + eventName, JSON.stringify(events));
|
|
465
|
+
// appStorage.set(LAST_EVENT_KEY, eventName);
|
|
466
|
+
|
|
467
|
+
// async Storage
|
|
468
|
+
await AsyncStorage.setItem(EVENT_KEY + eventName, JSON.stringify(events))
|
|
469
|
+
await AsyncStorage.setItem(LAST_EVENT_KEY, eventName)
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
} catch (error) {
|
|
473
|
+
console.error('Failed to store event:', error);
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
const handleFlushEvent = async (eventName, props) => {
|
|
478
|
+
try {
|
|
479
|
+
const storedEvents = await getEventData(EVENT_KEY + eventName);
|
|
480
|
+
let events = storedEvents ? JSON.parse(storedEvents) : [];
|
|
481
|
+
|
|
482
|
+
events.forEach(event => {
|
|
483
|
+
Object.assign(props, event.props);
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
await AppIceReactPlugin.tagEvent(eventName, props);
|
|
487
|
+
|
|
488
|
+
await deleteData(EVENT_KEY + eventName)
|
|
489
|
+
await deleteData(LAST_EVENT_KEY)
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
} catch (error) {
|
|
493
|
+
console.error('Failed to flush events:', error);
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
const deleteData = async (eventName) => {
|
|
498
|
+
try {
|
|
499
|
+
//appStorage.delete(EVENT_KEY + eventName);
|
|
500
|
+
//appStorage.delete(LAST_EVENT_KEY);
|
|
501
|
+
|
|
502
|
+
await AsyncStorage.removeItem(eventName)
|
|
503
|
+
} catch (error) {
|
|
504
|
+
console.error('Failed to delete events:', error);
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
const getEventData = async (eventName) => {
|
|
509
|
+
try {
|
|
510
|
+
|
|
511
|
+
// const storedEvents1 = appStorage.getString(EVENT_KEY + lastEventData);
|
|
512
|
+
|
|
513
|
+
return await AsyncStorage.getItem(eventName)
|
|
514
|
+
} catch (error) {
|
|
515
|
+
console.error('Failed to fetch events:', error);
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
|
|
400
519
|
|
|
401
520
|
module.exports = AppICEReact;
|
package/ios/AppIceReactPlugin.m
CHANGED
|
@@ -203,7 +203,7 @@ RCT_EXPORT_METHOD(setUser:(NSDictionary*)userProfile)
|
|
|
203
203
|
app.gender = userProfile[items[i]];
|
|
204
204
|
break;
|
|
205
205
|
case 4:
|
|
206
|
-
app.dob = [userProfile[items[i]]
|
|
206
|
+
app.dob = [userProfile[items[i]]longLongValue];
|
|
207
207
|
break;
|
|
208
208
|
case 5:
|
|
209
209
|
app.age = [userProfile[items[i] ]intValue];
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactnative-plugin-appice",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.15",
|
|
4
4
|
"description": "appICE React Native SDK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"react": "^16.9.0",
|
|
38
|
-
"react-native": "^0.61.5"
|
|
38
|
+
"react-native": "^0.61.5",
|
|
39
|
+
"@react-native-async-storage/async-storage": "1.21.0"
|
|
39
40
|
}
|
|
40
41
|
}
|