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
|
File without changes
|
package/example/App.js
CHANGED
|
@@ -13,8 +13,12 @@ import { Alert,
|
|
|
13
13
|
View,
|
|
14
14
|
AppState
|
|
15
15
|
} from 'react-native';
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// Define a type for the props parameter
|
|
17
|
+
type EventProps = {
|
|
18
|
+
[key: string]: string; // all values are strings
|
|
19
|
+
};
|
|
20
|
+
import { getInboxMessages, getMessageCounts, setUser, updatedInboxMessage } from './ancilliary';
|
|
21
|
+
import { handleUrl,receiveDeepLink } from './offerIdhandler';
|
|
18
22
|
const AppICE = require('reactnative-plugin-appice');
|
|
19
23
|
const HelloWorldApp = () => {
|
|
20
24
|
const certs: never[] = [];
|
|
@@ -280,4 +284,9 @@ const getUserData = () => {
|
|
|
280
284
|
});
|
|
281
285
|
};
|
|
282
286
|
|
|
287
|
+
const cacheOrFlushEvent = (event, segment, flush ) => {
|
|
288
|
+
AppICE.tagEvent(event, segment, flush)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
|
|
283
292
|
export default HelloWorldApp;
|
package/example/ancilliary.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* eslint-disable prettier/prettier */
|
|
2
2
|
const AppICE = require('reactnative-plugin-appice');
|
|
3
|
+
import { URL } from 'react-native-url-polyfill';
|
|
4
|
+
import { getInboxMessageForId , synchronizeInbox} from './App';
|
|
3
5
|
|
|
4
6
|
/* eslint-disable prettier/prettier */
|
|
5
7
|
/**
|
|
@@ -21,7 +23,7 @@ const setUser = (profile) => {
|
|
|
21
23
|
[AppICE.name]: profile.name,
|
|
22
24
|
[AppICE.phone]: phone,
|
|
23
25
|
[AppICE.email]: email,
|
|
24
|
-
[AppICE.dob]: profile.dob,
|
|
26
|
+
[AppICE.dob]: parseInt(profile.dob),
|
|
25
27
|
[AppICE.age]: age,
|
|
26
28
|
[AppICE.gender]: profile.gender,
|
|
27
29
|
[AppICE.educationType]: profile.educationType,
|
|
@@ -36,7 +38,7 @@ const setUser = (profile) => {
|
|
|
36
38
|
* @param {string} birthYear - Year of birth as a string (e.g., '1990')
|
|
37
39
|
* @returns {number} - Age in years
|
|
38
40
|
*/
|
|
39
|
-
const calculateAge = (birthYear
|
|
41
|
+
const calculateAge = (birthYear) => {
|
|
40
42
|
let age;
|
|
41
43
|
// Convert the birth year from string to integer
|
|
42
44
|
if(birthYear != null){
|
|
@@ -318,10 +320,155 @@ const setUser = (profile) => {
|
|
|
318
320
|
}
|
|
319
321
|
return false;
|
|
320
322
|
};
|
|
321
|
-
|
|
323
|
+
/**
|
|
324
|
+
* This function is made for arrange data according to required output
|
|
325
|
+
* they need json array which we do not support from pannel
|
|
326
|
+
* so we are sending it as string for Ex
|
|
327
|
+
* key = offerTexts
|
|
328
|
+
* value = {\"offerTexts\":[\"Customers transacting on BMS "]}",
|
|
329
|
+
* here we are parsing and arranging it according to their need
|
|
330
|
+
* apart from json array we are also sending String and json object
|
|
331
|
+
* @param {JSON} cdata this is data what we are getting from getMessagebyId
|
|
332
|
+
* @param {*} offerid this may be a string valur or null
|
|
333
|
+
* @returns jsonObject
|
|
334
|
+
*/
|
|
335
|
+
const formatOfferData = (cdata,offerid) => {
|
|
336
|
+
const formattedData = {};
|
|
337
|
+
|
|
338
|
+
// Ensure offerId is the first item in data
|
|
339
|
+
if (offerid != null) {
|
|
340
|
+
formattedData.offerId = offerid;
|
|
341
|
+
}
|
|
342
|
+
if (!cdata || Object.keys(cdata).length === 0) {
|
|
343
|
+
return formattedData;
|
|
344
|
+
}
|
|
345
|
+
const isValidJsonString = (str) => {
|
|
346
|
+
if (typeof str !== 'string') {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
try {
|
|
350
|
+
JSON.parse(str);
|
|
351
|
+
return true;
|
|
352
|
+
} catch (e) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
const parseValue = (value) => {
|
|
358
|
+
if (typeof value === 'string' && isValidJsonString(value)) {
|
|
359
|
+
try {
|
|
360
|
+
const parsed = JSON.parse(value);
|
|
361
|
+
if (Array.isArray(parsed)) {
|
|
362
|
+
return parsed;
|
|
363
|
+
} else if (typeof parsed === 'object') {
|
|
364
|
+
const keys = Object.keys(parsed);
|
|
365
|
+
if (keys.length === 1 && Array.isArray(parsed[keys[0]])) {
|
|
366
|
+
return parsed[keys[0]];
|
|
367
|
+
} else {
|
|
368
|
+
return parsed;
|
|
369
|
+
}
|
|
370
|
+
} else {
|
|
371
|
+
return value;
|
|
372
|
+
}
|
|
373
|
+
} catch (error) {
|
|
374
|
+
return value;
|
|
375
|
+
}
|
|
376
|
+
} else {
|
|
377
|
+
return value;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
// Loop through cdata keys
|
|
383
|
+
Object.keys(cdata).forEach((key) => {
|
|
384
|
+
formattedData[key] = parseValue(cdata[key]);
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
return formattedData;
|
|
388
|
+
};
|
|
389
|
+
/**
|
|
390
|
+
* This function will recive mid userId and offerID
|
|
391
|
+
* with mid and userId it will call native function and retrive data
|
|
392
|
+
* This will retrive InboxMessage for given messageId
|
|
393
|
+
* from recived response we are getting only cData and pass it be formatted
|
|
394
|
+
*
|
|
395
|
+
* @param {String} messageId unique id of message you can get from inboxMessage
|
|
396
|
+
* @param {String} useIds this is id of user you can get it from getUserId
|
|
397
|
+
* @param {*} offerid in case of inbox this will be null from dl we are retriving it
|
|
398
|
+
* @param {Object} callback callback the response
|
|
399
|
+
*/
|
|
400
|
+
export const getOfferDataForInboxMessage = (messageId, useIds, offerid, callback) => {
|
|
401
|
+
AppICE.getInboxMessageForId(messageId, useIds, (inboxMessage) => {
|
|
402
|
+
const offerData = formatOfferData(inboxMessage.cdata,offerid);
|
|
403
|
+
const result = { data: offerData };
|
|
404
|
+
callback(result);
|
|
405
|
+
});
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* This function will recive dl URL and user ID
|
|
410
|
+
* Ex boiua://offers?offerid=1234&mid=37ce1de6-3b63-4182-a5df-2334d5b13750
|
|
411
|
+
* retrive offerid and mid from dl URL
|
|
412
|
+
* useIds you have to getit from appSide
|
|
413
|
+
*
|
|
414
|
+
* @param {string} dl The deep link URL from which to extract the 'mid' parameter.
|
|
415
|
+
* @param {string} useId user id
|
|
416
|
+
* @param {object} callback return the response
|
|
417
|
+
*/
|
|
418
|
+
const getOfferDataForDeeplink = (dl,userId,callback) =>{
|
|
419
|
+
const mid = extractMidFromDeepLink(dl);
|
|
420
|
+
const offerid = extractOfferIdFromDeepLink(dl);
|
|
421
|
+
if(mid != null){
|
|
422
|
+
synchronizeInbox();
|
|
423
|
+
getOfferDataForInboxMessage(mid, userId, offerid, (result) => {
|
|
424
|
+
callback(result);
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* We will recive dl when it is being clicked
|
|
430
|
+
* from that method this method will be called
|
|
431
|
+
* it check if there is mid it will return mid value
|
|
432
|
+
* @param {string} dl Deep Link URL Ex boiua://offers?offerid=1234&mid=37ce1de6-3b63-4182-a5df-2334d5b13750
|
|
433
|
+
* @returns {string} mid Ex 37ce1de6-3b63-4182-a5df-2334d5b13750
|
|
434
|
+
*/
|
|
435
|
+
const extractMidFromDeepLink = (dl) => {
|
|
436
|
+
try {
|
|
437
|
+
const url = new URL(dl);
|
|
438
|
+
const mid = url.searchParams.get('mid');
|
|
439
|
+
if (mid) {
|
|
440
|
+
return mid;
|
|
441
|
+
} else {
|
|
442
|
+
console.log("'mid' parameter not found in the deep link");
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
} catch (error) {
|
|
446
|
+
console.error('Invalid URL:', error);
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const extractOfferIdFromDeepLink = (dl) => {
|
|
451
|
+
try {
|
|
452
|
+
const url = new URL(dl);
|
|
453
|
+
const offerid = url.searchParams.get('offerid');
|
|
454
|
+
if (offerid) {
|
|
455
|
+
return offerid;
|
|
456
|
+
} else {
|
|
457
|
+
console.log("'offerid' parameter not found in the deep link");
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
} catch (error) {
|
|
461
|
+
console.error('Invalid URL:', error);
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
|
|
322
467
|
module.exports = {
|
|
323
468
|
getInboxMessages,
|
|
324
469
|
updatedInboxMessage,
|
|
325
470
|
setUser,
|
|
326
471
|
getMessageCounts,
|
|
472
|
+
getOfferDataForDeeplink,
|
|
473
|
+
getOfferDataForInboxMessage,
|
|
327
474
|
};
|
package/example/android/gradlew
CHANGED
|
File without changes
|
package/example/package.json
CHANGED
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
"lint": "eslint ."
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
+
"@react-native-async-storage/async-storage": "^1.23.1",
|
|
13
14
|
"@react-native-firebase/app": "^15.3.0",
|
|
14
15
|
"@react-native-firebase/messaging": "^15.3.0",
|
|
15
16
|
"@react-navigation/native-stack": "^6.7.0",
|
|
16
17
|
"install": "^0.13.0",
|
|
17
18
|
"react": "18.0.0",
|
|
18
19
|
"react-native": "0.69.4",
|
|
19
|
-
"reactnative-plugin-appice": "
|
|
20
|
+
"reactnative-plugin-appice": "1.7.13",
|
|
21
|
+
"react-native-mmkv": "2.12.2"
|
|
20
22
|
},
|
|
21
23
|
"devDependencies": {
|
|
22
24
|
"@babel/core": "^7.12.9",
|