reactnative-plugin-appice 1.6.9 → 1.7.1

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.
@@ -114,8 +114,7 @@ dependencies {
114
114
  annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.3.1"
115
115
 
116
116
  //appice
117
- implementation 'appice.io.android:sdk:2.5.71'
118
- //implementation files('libs/libsdk-release.aar')
117
+ implementation 'appice.io.android:sdk:2.5.73'
119
118
 
120
119
  //glide
121
120
  implementation "com.github.bumptech.glide:glide:4.11.0"
@@ -54,11 +54,14 @@ public class AppICEUtils {
54
54
  userObject.putString(EnumConstants.APPICE_USER_EMAIL.getValue(), user.getEmail());
55
55
  userObject.putDouble(EnumConstants.APPICE_DATE_OF_BIRTH.getValue(), user.getDob());
56
56
  userObject.putInt(EnumConstants.APPICE_USER_AGE.getValue(), user.getAge());
57
- userObject.putString(EnumConstants.APPICE_USER_EDUCATION.getValue(), user.getEducationType());
57
+ userObject.putString(EnumConstants.APPICE_USER_EDUCATION_TYPE.getValue(), user.getEducationType());
58
58
  userObject.putString(EnumConstants.APPICE_USER_GENDER.getValue(), user.getGender());
59
59
  userObject.putBoolean(EnumConstants.APPICE_USER_IS_EMPLOYED.getValue(), user.isEmployed());
60
60
  userObject.putString(EnumConstants.APPICE_USER_EMPLOYMENT_TYPE.getValue(), user.getEmploymentType());
61
61
  userObject.putBoolean(EnumConstants.APPICE_USER_MARRIED.getValue(), user.isMarried());
62
+ if (user.getCustomProperties() != null && user.getCustomProperties().length() > 0) {
63
+ userObject.putString(EnumConstants.DEMOGRAPHIC_INFO.getValue(), user.getCustomProperties().toString());
64
+ }
62
65
  }
63
66
  } catch (Throwable e) {
64
67
  }
@@ -22,8 +22,10 @@ import semusi.activitysdk.SdkConfig;
22
22
  import semusi.activitysdk.User;
23
23
  import semusi.context.ui.appInbox.AppICEInboxMessage;
24
24
  import semusi.context.ui.appInbox.IAppICESuccessCallback;
25
+ import semusi.activitysdk.IAppICEDataCallback;
25
26
  import java.util.*;
26
27
 
28
+
27
29
  import androidx.annotation.NonNull;
28
30
  import androidx.annotation.Nullable;
29
31
 
@@ -310,21 +312,11 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
310
312
  try {
311
313
  User user = ContextSdk.getUser(context);
312
314
  if (user != null) {
313
- userObject.putString(EnumConstants.APPICE_USER_NAME.getValue(), user.getName());
314
- userObject.putString(EnumConstants.APPICE_USER_EMAIL.getValue(), user.getEmail());
315
- userObject.putInt(EnumConstants.APPICE_USER_AGE.getValue(), user.getAge());
316
- userObject.putDouble(EnumConstants.APPICE_DATE_OF_BIRTH.getValue(), user.getDob());
317
- userObject.putString(EnumConstants.APPICE_USER_EDUCATION.getValue(), user.getEducationType());
318
- userObject.putString(EnumConstants.APPICE_USER_EMPLOYMENT_TYPE.getValue(), user.getEmploymentType());
319
- userObject.putString(EnumConstants.APPICE_USER_GENDER.getValue(), user.getGender());
320
- userObject.putString(EnumConstants.APPICE_USER_PHONE.getValue(), user.getPhone());
321
- if (user.getCustomProperties() != null && user.getCustomProperties().length() > 0) {
322
- userObject.putString(EnumConstants.DEMOGRAPHIC_INFO.getValue(), user.getCustomProperties().toString());
323
- }
315
+ userObject = AppICEUtils.convertUserClassToWritableMap(user);
324
316
  callback.invoke(userObject);
325
317
  }
326
318
  } catch (Throwable t) {
327
- callback.invoke(t);
319
+ callback.invoke(t.getMessage());
328
320
  }
329
321
  }
330
322
 
@@ -486,7 +478,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
486
478
  }
487
479
  callback.invoke(writableArray);
488
480
  } catch (Throwable e) {
489
- callback.invoke(e);
481
+ callback.invoke(e.getMessage());
490
482
  }
491
483
  }
492
484
  /**
@@ -497,7 +489,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
497
489
  * @param callback will return instance of User class
498
490
  */
499
491
  @ReactMethod
500
- public void getUser(ReadableArray userIds, Callback callback) {
492
+ public void getUserForIds(ReadableArray userIds, Callback callback) {
501
493
  Context context = getReactApplicationContext();
502
494
  WritableArray writableArray = Arguments.createArray();
503
495
  try {
@@ -513,7 +505,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
513
505
  // return callback
514
506
  callback.invoke(writableArray);
515
507
  } catch (Throwable e) {
516
- callback.invoke(e);
508
+ callback.invoke(e.getMessage());
517
509
  }
518
510
  }
519
511
  /**
@@ -524,15 +516,20 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
524
516
  public void synchronizeData(int timeout, Callback callback) {
525
517
  Context context = getReactApplicationContext();
526
518
  try {
527
- ContextSdk.synchronizeData(new IAppICESuccessCallback(){
519
+ ContextSdk.synchronizeData(new IAppICEDataCallback(){
528
520
  @Override
529
- public void callback(boolean isDataRefreshed) {
530
- callback.invoke(isDataRefreshed);
521
+ public void onSuccess() {
522
+ callback.invoke(true);
523
+ }
524
+ @Override
525
+ public void onFailure(String message) {
526
+ callback.invoke(false);
531
527
  }
532
528
  }, timeout, context);
533
529
  } catch (Throwable e) {
534
- callback.invoke(e);
530
+ callback.invoke(e.getMessage());
535
531
  }
532
+
536
533
  }
537
534
  /**
538
535
  * Get inbox messages count.
@@ -558,7 +555,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
558
555
  }
559
556
  callback.invoke(count);
560
557
  } catch (Throwable e) {
561
- callback.invoke(e);
558
+ callback.invoke(e.getMessage());
562
559
  }
563
560
  }
564
561
 
@@ -576,7 +573,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
576
573
  AppICEInboxMessage inboxMessage = ContextSdk.getInboxMessageForId(messageId, userId, context);
577
574
  callback.invoke(AppICEUtils.convertClassToWritableMap(inboxMessage));
578
575
  } catch (Throwable e) {
579
- callback.invoke(e);
576
+ callback.invoke(e.getMessage());
580
577
  }
581
578
  }
582
579
 
@@ -595,7 +592,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
595
592
  boolean isUpdated = ContextSdk.updatedInboxMessage(messageId, type, userId, context);
596
593
  callback.invoke(isUpdated);
597
594
  } catch (Throwable e) {
598
- callback.invoke(e);
595
+ callback.invoke(e.getMessage());
599
596
  }
600
597
  }
601
598
 
@@ -617,7 +614,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
617
614
  }
618
615
  }, timeout, context);
619
616
  } catch (Throwable e) {
620
- callback.invoke(e);
617
+ callback.invoke(e.getMessage());
621
618
  }
622
619
  }
623
620
 
@@ -659,6 +656,8 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
659
656
  constants.put(EnumConstants.APPICE_USER_NAME.getConstants(), EnumConstants.APPICE_USER_NAME.getValue());
660
657
  constants.put(EnumConstants.APPICE_USER_PHONE.getConstants(), EnumConstants.APPICE_USER_PHONE.getValue());
661
658
  constants.put(EnumConstants.APPICE_USER_EMAIL.getConstants(), EnumConstants.APPICE_USER_EMAIL.getValue());
659
+ constants.put(EnumConstants.APPICE_DATE_OF_BIRTH.getConstants(), EnumConstants.APPICE_DATE_OF_BIRTH.getValue());
660
+ constants.put(EnumConstants.APPICE_USER_EDUCATION_TYPE.getConstants(), EnumConstants.APPICE_USER_EDUCATION_TYPE.getValue());
662
661
  constants.put(EnumConstants.APPICE_USER_IS_EMPLOYED.getConstants(), EnumConstants.APPICE_USER_IS_EMPLOYED.getValue());
663
662
  constants.put(EnumConstants.APPICE_USER_MARRIED.getConstants(), EnumConstants.APPICE_USER_MARRIED.getValue());
664
663
  constants.put(EnumConstants.APPICE_USER_EDUCATION.getConstants(), EnumConstants.APPICE_USER_EDUCATION.getValue());
@@ -1,5 +1,9 @@
1
1
  package com.reactlibrary;
2
-
2
+ import semusi.activitysdk.UserInfoConstants;
3
+ import semusi.context.utility.AppICEConstants;
4
+ import semusi.activitysdk.CustomUserPropertyConstants;
5
+ import semusi.activitysdk.Ecommerce;
6
+ import semusi.activitysdk.FinancialServices;
3
7
  //Common place for constant and SDK constants
4
8
  public enum EnumConstants {
5
9
 
@@ -18,6 +22,7 @@ public enum EnumConstants {
18
22
  APPICE_USER_IS_EMPLOYED("APPICE_USER_IS_EMPLOYED"),
19
23
  APPICE_USER_EMPLOYMENT_TYPE ("APPICE_USER_EMPLOYMENT_TYPE"),
20
24
  APPICE_USER_MARRIED("APPICE_USER_MARRIED"),
25
+ APPICE_USER_EDUCATION_TYPE("APPICE_USER_EDUCATION_TYPE"),
21
26
 
22
27
  //===========================
23
28
  //PUSH
@@ -89,43 +94,47 @@ public enum EnumConstants {
89
94
  public String getValue(){
90
95
  switch (constants){
91
96
  case "APPICE_USER_NAME":{
92
- return "n";
97
+ return UserInfoConstants.NAME;
93
98
  }
94
99
 
95
100
  case "APPICE_USER_PHONE":{
96
- return "ph";
101
+ return UserInfoConstants.PHONE;
97
102
  }
98
103
 
99
104
  case "APPICE_USER_EMAIL":{
100
- return "em";
105
+ return UserInfoConstants.EMAIL;
101
106
  }
102
-
107
+
103
108
  case "APPICE_DATE_OF_BIRTH":{
104
- return "dob";
109
+ return UserInfoConstants.DATE_OF_BIRTH;
105
110
  }
106
111
 
107
112
  case "APPICE_USER_AGE":{
108
- return "a";
113
+ return UserInfoConstants.AGE;
109
114
  }
110
115
 
116
+ case "APPICE_USER_EDUCATION_TYPE":{
117
+ return UserInfoConstants.EDUCATION_TYPE;
118
+ }
119
+
111
120
  case "APPICE_USER_EDUCATION":{
112
121
  return "ed";
113
122
  }
114
123
 
115
124
  case "APPICE_USER_GENDER":{
116
- return "g";
125
+ return UserInfoConstants.GENDER;
117
126
  }
118
127
 
119
128
  case "APPICE_USER_IS_EMPLOYED":{
120
- return "is_emp";
129
+ return UserInfoConstants.EMPLOYEE_STATUS;
121
130
  }
122
131
 
123
132
  case "APPICE_USER_EMPLOYMENT_TYPE":{
124
- return "et";
133
+ return UserInfoConstants.EMPLOYMENT_TYPE;
125
134
  }
126
135
 
127
136
  case "APPICE_USER_MARRIED":{
128
- return "m";
137
+ return UserInfoConstants.RELATIONSHIP_STATUS;
129
138
  }
130
139
 
131
140
  case "APPICE_PUSH_NOTIFICATION_CLICKED":{
@@ -141,7 +150,7 @@ public enum EnumConstants {
141
150
  }
142
151
 
143
152
  case "INBOX_TITLE":{
144
- return "title";
153
+ return AppICEConstants.TITLE;
145
154
  }
146
155
 
147
156
  case "INBOX_MESSAGE_STATUS":{
@@ -185,65 +194,64 @@ public enum EnumConstants {
185
194
  }
186
195
 
187
196
  case "TOP_N_PRODUCTS_VIEWED":{
188
- return "tn";
197
+ return CustomUserPropertyConstants.TOP_N_PRODUCTS_VIEWED;
189
198
  }
190
199
 
191
200
  case "N_COMPLAINTS_RAISED":{
192
- return "nc";
201
+ return CustomUserPropertyConstants.N_COMPLAINTS_RAISED;
193
202
  }
194
203
 
195
204
  case "PREF_LOGIN_DEVICE":{
196
- return "pl";
205
+ return CustomUserPropertyConstants.PREF_LOGIN_DEVICE;
197
206
  }
198
207
 
199
208
  case "REFERRAL_CAMPAIGN":{
200
- return "rc";
209
+ return CustomUserPropertyConstants.REFERRAL_CAMPAIGN;
201
210
  }
202
211
 
203
212
  case "DEMOGRAPHIC_INFO":{
204
- return "customProperties";
213
+ return UserInfoConstants.DEMOGRAPHIC_INFO;
205
214
  }
206
215
 
207
216
  case "TOTAL_ORDER_VALUE":{
208
- return "tv";
217
+ return Ecommerce.TOTAL_ORDER_VALUE;
209
218
  }
210
219
 
211
220
  case "ADD_TO_CART_N_DAYS":{
212
- return "an";
221
+ return Ecommerce.ADD_TO_CART_N_DAYS;
213
222
  }
214
223
 
215
224
  case "FINANCIAL_SERVICES":{
216
- return "fs";
225
+ return FinancialServices.FINANCIAL_SERVICES;
217
226
  }
218
227
 
219
228
  case "CREDIT_SCORE":{
220
- return "cs";
229
+ return FinancialServices.CREDIT_SCORE;
221
230
  }
222
231
 
223
232
  case "DEBT_TO_INCOME_RATIO":{
224
- return "di";
233
+ return FinancialServices.DEBT_TO_INCOME_RATIO;
225
234
  }
226
235
 
227
236
  case "SAVINGS_BALANCE":{
228
- return "sb";
237
+ return FinancialServices.SAVINGS_BALANCE;
229
238
  }
230
239
 
231
240
  case "CHECKING_BALANCE":{
232
- return "cb";
241
+ return FinancialServices.CHECKING_BALANCE;
233
242
  }
234
243
 
235
244
  case "AVERAGE_TRANSACTION_AMOUNT":{
236
- return "at";
245
+ return FinancialServices.AVERAGE_TRANSACTION_AMOUNT;
237
246
  }
238
247
 
239
248
  case "FREQUENCY_OF_TRANSACTION":{
240
- return "ft";
249
+ return FinancialServices.FREQUENCY_OF_TRANSACTION;
241
250
  }
242
251
 
243
252
  case "TYPE_OF_TRANSACTION":{
244
- return "tt";
253
+ return FinancialServices.TYPE_OF_TRANSACTION;
245
254
  }
246
-
247
255
  default:
248
256
  return "";
249
257
  }
package/example/App.js CHANGED
@@ -265,24 +265,45 @@ const getMessageCount = () => {
265
265
  }
266
266
 
267
267
  const getUserData = () => {
268
- AppICE.synchronizeData(10, (success: boolean) => {
268
+ AppICE.synchronizeData(10,(success: boolean) => {
269
269
  console.log('Profile synchronization success:', success);
270
270
  Alert.alert(`synchronizeData: \n ${success}`);
271
271
  const userIds = ['160840156'];
272
- AppICE.getUser(userIds, (res:any[]) => {
272
+ AppICE.getUserForIds(userIds, (res:any[]) => {
273
273
 
274
274
  console.log('Receive getUser:', res);
275
275
  for (var index = 0; index < res.length; index++) {
276
276
  let userData = res[index];
277
- console.log('Received getUser data:', userData);
277
+ console.log('Received Inbox:', userData);
278
278
  const name = userData[AppICE.name];
279
279
  const phone = userData[AppICE.phone];
280
- console.log('GetUser Name:', name);
281
- console.log('GetUser PHONE:', phone);
282
-
283
- }
280
+ const gender = userData[AppICE.gender];
281
+ const dob = userData[AppICE.dob];
282
+ const edt = userData[AppICE.educationType];
283
+ const email = userData[AppICE.email];
284
+ const employment = userData[AppICE.employmentType];
285
+ const age = userData[AppICE.age];
286
+ const marriage = userData[AppICE.married];
287
+ const isEmployed = userData[AppICE.isEmployed];
288
+
289
+ console.log('GetUser name:', name);
290
+ console.log('GetUser phone:', phone);
291
+ console.log('GetUser gender:', gender);
292
+ console.log('GetUser dob:', dob);
293
+ console.log('GetUser educationType:', edt);
294
+ console.log('GetUser email:', email);
295
+ console.log('GetUser employment:', employment);
296
+ console.log('GetUser age:', age);
297
+ console.log('GetUser marriage:', marriage);
298
+ console.log('GetUser isEmployed:', isEmployed);
299
+
300
+
301
+ const customProperties = userData[AppICE.DEMOGRAPHIC_INFO];
302
+ const customPropertiesObj = JSON.parse(customProperties);
303
+ console.log("user Profile, top_n_product_viewed = "+customPropertiesObj[AppICE.TOP_N_PRODUCTS_VIEWED]);
304
+
305
+ }
284
306
  });
285
-
286
307
  });
287
308
  }
288
309
 
@@ -0,0 +1,8 @@
1
+ ## This file must *NOT* be checked into Version Control Systems,
2
+ # as it contains information specific to your local configuration.
3
+ #
4
+ # Location of the SDK. This is only used by Gradle.
5
+ # For customization when using a Version Control System, please read the
6
+ # header note.
7
+ #Thu Feb 01 13:23:35 IST 2024
8
+ sdk.dir=/Users/amit/Library/Android/sdk
@@ -16,7 +16,7 @@
16
16
  "install": "^0.13.0",
17
17
  "react": "18.0.0",
18
18
  "react-native": "0.69.4",
19
- "reactnative-plugin-appice": "^1.6.9"
19
+ "reactnative-plugin-appice": "^1.7.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@babel/core": "^7.12.9",
package/index.js CHANGED
@@ -41,15 +41,16 @@ var AppICEReact = {
41
41
  //=======================
42
42
  // USER-PROFILE SETTING
43
43
  //=======================
44
- name: AppIceReactPlugin.n,
45
- email: AppIceReactPlugin.em,
46
- phone: AppIceReactPlugin.ph,
47
- age: AppIceReactPlugin.a,
48
- gender: AppIceReactPlugin.g,
49
- educationType: AppIceReactPlugin.ed,
50
- employmentType: AppIceReactPlugin.et,
51
- married: AppIceReactPlugin.m,
52
- isEmployed: AppIceReactPlugin.is_emp,
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,
53
54
 
54
55
 
55
56
  TOP_N_PRODUCTS_VIEWED: AppIceReactPlugin.TOP_N_PRODUCTS_VIEWED,
@@ -369,11 +370,11 @@ var AppICEReact = {
369
370
  },
370
371
 
371
372
  /*===================
372
- getUser with userIds
373
+ getUserForIds with userIds
373
374
  =====================*/
374
375
 
375
- getUser: function (userIds, callback) {
376
- callWithCallback('getUser', [userIds], callback);
376
+ getUserForIds: function (userIds, callback) {
377
+ callWithCallback('getUserForIds', [userIds], callback);
377
378
  },
378
379
  };
379
380
  //================================
@@ -3,17 +3,17 @@
3
3
  static NSString *const kAppICEPushNotificationClicked = @"AppICEPushNotificationClicked";
4
4
  static NSString *const kAppICEInAppClicked = @"AppICEInAppClicked";
5
5
 
6
- static NSString *const kn = @"n";
7
- static NSString *const kem = @"em";
8
- static NSString *const kph = @"ph";
9
- static NSString *const ka = @"a";
10
- static NSString *const kg = @"g";
11
- static NSString *const ked = @"ed";
12
- static NSString *const ket = @"et";
13
- static NSString *const km = @"m";
14
- static NSString *const kis_emp = @"is_emp";
6
+ static NSString *const kn = @"APPICE_USER_NAME";
7
+ static NSString *const kem = @"APPICE_USER_EMAIL";
8
+ static NSString *const kph = @"APPICE_USER_PHONE";
9
+ static NSString *const ka = @"APPICE_USER_AGE";
10
+ static NSString *const kg = @"APPICE_USER_GENDER";
11
+ static NSString *const ked = @"APPICE_USER_EDUCATION_TYPE";
12
+ static NSString *const ket = @"APPICE_USER_EMPLOYMENT_TYPE";
13
+ static NSString *const km = @"APPICE_USER_MARRIED";
14
+ static NSString *const kis_emp = @"APPICE_USER_IS_EMPLOYED";
15
15
  static NSString *const kappICEToken = @"appICEToken";
16
- static NSString *const kdob = @"d";
16
+ static NSString *const kdob = @"APPICE_DATE_OF_BIRTH";
17
17
 
18
18
 
19
19
 
@@ -34,15 +34,16 @@ RCT_EXPORT_MODULE()
34
34
  return @{
35
35
  kAppICEPushNotificationClicked : kAppICEPushNotificationClicked,
36
36
  kAppICEInAppClicked : kAppICEInAppClicked,
37
- kn : kn,
37
+ kn : @"n",
38
38
  kem : @"e",
39
39
  kph : @"p",
40
- ka : ka,
41
- kg : kg,
40
+ ka : @"a",
41
+ kg : @"g",
42
42
  ked : @"edt",
43
43
  ket : @"emt",
44
- km : km,
44
+ km : @"m",
45
45
  kis_emp : @"em",
46
+ kdob: @"d",
46
47
 
47
48
  INBOX_MESSAGE : @"message",
48
49
  INBOX_TITLE : @"title",
@@ -602,12 +603,12 @@ RCT_EXPORT_METHOD(synchronizeData:(int)timeout callback:(RCTResponseSenderBlock)
602
603
  }
603
604
 
604
605
  /*--------------------------------------------
605
- * getUser with UserId
606
+ * getUserForIds with UserId
606
607
  * userIds - NSArray
607
608
  * @callback will have the boolean
608
609
  ---------------------------------------------*/
609
610
 
610
- RCT_EXPORT_METHOD(getUser:(NSArray*)userIds callback:(RCTResponseSenderBlock)callback)
611
+ RCT_EXPORT_METHOD(getUserForIds:(NSArray*)userIds callback:(RCTResponseSenderBlock)callback)
611
612
  {
612
613
  NSMutableArray *getUserArray =[[appICEUserDetails sharedUserDetails] getUser:userIds];
613
614
  // Convert appICEUserDetails objects to dictionaries
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactnative-plugin-appice",
3
- "version": "1.6.9",
3
+ "version": "1.7.1",
4
4
  "description": "appICE React Native SDK",
5
5
  "main": "index.js",
6
6
  "files": [
File without changes
File without changes