reactnative-plugin-appice 1.6.2 → 1.6.4

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.
@@ -1,5 +1,8 @@
1
1
  package com.reactlibrary;
2
2
 
3
+ import static com.reactlibrary.AppICEUtils.arrayListStringFromReadableArray;
4
+ import static com.reactlibrary.AppICEUtils.eventPropsFromReadableMap;
5
+
3
6
  import android.content.Context;
4
7
  import android.content.Intent;
5
8
  import android.content.pm.PackageManager;
@@ -23,6 +26,8 @@ import semusi.activitysdk.Api;
23
26
  import semusi.activitysdk.ContextSdk;
24
27
  import semusi.activitysdk.SdkConfig;
25
28
  import semusi.activitysdk.User;
29
+ import semusi.context.ui.appInbox.AppICEInboxMessage;
30
+ import semusi.context.ui.appInbox.IAppICESuccessCallback;
26
31
 
27
32
  import java.util.*;
28
33
 
@@ -31,6 +36,7 @@ import androidx.annotation.NonNull;
31
36
  import androidx.annotation.Nullable;
32
37
 
33
38
  import com.facebook.react.bridge.ReadableArray;
39
+ import com.facebook.react.bridge.WritableArray;
34
40
  import com.facebook.react.bridge.WritableMap;
35
41
  import com.facebook.react.modules.core.DeviceEventManagerModule;
36
42
 
@@ -40,20 +46,8 @@ import org.json.JSONObject;
40
46
 
41
47
  public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
42
48
  private static ReactApplicationContext context = null;
43
- private static final String TAG = "AppIceReactPluginModule";
44
- private static final String APPICE_USER_NAME = "n";
45
- private static final String APPICE_USER_PHONE = "ph";
46
- private static final String APPICE_USER_EMAIL = "em";
47
- private static final String dateOfBirth = "dob";
48
- private static final String APPICE_USER_AGE = "a";
49
- private static final String APPICE_USER_EDUCATION = "ed";
50
- private static final String APPICE_USER_GENDER = "g";
51
- private static final String APPICE_USER_IS_EMPLOYED = "is_emp";
52
- private static final String APPICE_USER_EMPLOYMENT_TYPE = "et";
53
- private static final String APPICE_USER_MARRIED = "m";
54
- public static final String APPICE_PUSH_NOTIFICATION_CLICKED = "AppICEPushNotificationClicked";
55
- public static final String APPICE_INAPP_NOTIFICATION_CLICKED = "AppICEInAppClicked";
56
-
49
+ private static final String TAG = "AppIceReactPlugin";
50
+
57
51
  public AppIceReactPluginModule(ReactApplicationContext reactContext) {
58
52
  super(reactContext);
59
53
  context = reactContext;
@@ -79,7 +73,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
79
73
  String region, String baseUrl, ReadableArray certs
80
74
  ) {
81
75
  Context context = getReactApplicationContext();
82
- Log.d(TAG, "in startContext : appID : " + appID + ", appkey : " + appKey + ", apiKey : " + apiKey);
76
+ AppICEUtils.printLog(TAG, "in startContext : appID : " + appID + ", appkey : " + appKey + ", apiKey : " + apiKey);
83
77
  try {
84
78
  SdkConfig config = new SdkConfig();
85
79
  config.setAnalyticsTrackingAllowedState(true);
@@ -102,7 +96,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
102
96
  Api.startContext(context, config);
103
97
 
104
98
  } catch (Exception e) {
105
- Log.d(TAG, "Exception in startContext : " + e);
99
+ AppICEUtils.printLog(TAG, "Exception in startContext : " + e);
106
100
  }
107
101
  }
108
102
 
@@ -118,7 +112,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
118
112
  ContextSdk.tagEventObj(eventName, mapData, context);
119
113
  }
120
114
  } catch (Exception e) {
121
- Log.d(TAG, "Exception in tagEvent : " + e);
115
+ AppICEUtils.printLog(TAG, "Exception in tagEvent : " + e);
122
116
  }
123
117
  }
124
118
 
@@ -131,7 +125,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
131
125
  ContextSdk.setCustomVariable(eventName, (String) value, context);
132
126
  }
133
127
  } catch (Exception e) {
134
- Log.d(TAG, "Exception in customVar : " + e);
128
+ AppICEUtils.printLog(TAG, "Exception in customVar : " + e);
135
129
  }
136
130
  }
137
131
 
@@ -148,29 +142,29 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
148
142
  receiverIntent.setClass(ctx, CampaignCampsReceiver.class);
149
143
  List<ResolveInfo> receivers = pm.queryBroadcastReceivers(receiverIntent, 0);
150
144
  if (receivers == null || receivers.size() <= 0) {
151
- Log.d(TAG, "Missing Receiver entry in AndroidManifest : CampaignCampsReceiver");
145
+ AppICEUtils.printLog(TAG, "Missing Receiver entry in AndroidManifest : CampaignCampsReceiver");
152
146
  }
153
147
  Intent serviceIntent = new Intent();
154
148
  serviceIntent.setClass(ctx, NotificationEventService.class);
155
149
  ResolveInfo services = pm.resolveService(serviceIntent, 0);
156
150
  if (services == null) {
157
- Log.d(TAG, "Missing Service entry in AndroidManifest : NotificationEventService");
151
+ AppICEUtils.printLog(TAG, "Missing Service entry in AndroidManifest : NotificationEventService");
158
152
  }
159
153
 
160
154
  ContextSdk sdk = new ContextSdk(ctx);
161
155
  if (sdk.getAppId() == null || sdk.getAppId().length() <= 0 || sdk.getAppId().trim().length() <= 0) {
162
- Log.d(TAG, "Missing Meta-data entry : AppID");
156
+ AppICEUtils.printLog(TAG, "Missing Meta-data entry : AppID");
163
157
  }
164
158
 
165
159
  if (sdk.getAppKey() == null || sdk.getAppKey().length() <= 0 || sdk.getAppKey().trim().length() <= 0) {
166
- Log.d(TAG, "Missing Meta-data entry : AppKey");
160
+ AppICEUtils.printLog(TAG, "Missing Meta-data entry : AppKey");
167
161
  }
168
162
 
169
163
  if (sdk.getApiKey() == null || sdk.getApiKey().length() <= 0 || sdk.getApiKey().trim().length() <= 0) {
170
- Log.d(TAG, "Missing Meta-data entry : ApiKey");
164
+ AppICEUtils.printLog(TAG, "Missing Meta-data entry : ApiKey");
171
165
  }
172
166
  } catch (Exception e) {
173
- Log.d(TAG, "validateIntegration: " + e.getMessage());
167
+ AppICEUtils.printLog(TAG, "validateIntegration: " + e.getMessage());
174
168
  }
175
169
  }
176
170
 
@@ -178,121 +172,121 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
178
172
  public void setUser(ReadableMap userDetails) {
179
173
  Context context = getReactApplicationContext();
180
174
 
181
- Log.d(TAG, "setUser: " + userDetails);
175
+ AppICEUtils.printLog(TAG, "setUser: " + userDetails);
182
176
  HashMap<String, Object> map = eventPropsFromReadableMap(userDetails);
183
177
 
184
178
  if (map != null) {
185
179
  try {
186
180
  User user = new User();
187
181
  try {
188
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_NAME)) {
189
- Object name = map.get(AppIceReactPluginModule.APPICE_USER_NAME);
182
+ if (map.containsKey(Constants.APPICE_USER_NAME)) {
183
+ Object name = map.get(Constants.APPICE_USER_NAME);
190
184
  if (name != null) {
191
185
  user.setName(name.toString());
192
186
  }
193
187
  }
194
188
  } catch (Exception e) {
195
- Log.d(TAG, "setUser: name issue "+e.getMessage());
189
+ AppICEUtils.printLog(TAG, "setUser: name issue "+e.getMessage());
196
190
  }
197
191
 
198
192
  try {
199
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_PHONE)) {
200
- Object phone = map.get(AppIceReactPluginModule.APPICE_USER_PHONE);
193
+ if (map.containsKey(Constants.APPICE_USER_PHONE)) {
194
+ Object phone = map.get(Constants.APPICE_USER_PHONE);
201
195
  if (phone != null) {
202
196
  user.setPhone(phone.toString());
203
197
  }
204
198
  }
205
199
  } catch (Exception e) {
206
- Log.d(TAG, "setUser: phone issue "+e.getMessage());
200
+ AppICEUtils.printLog(TAG, "setUser: phone issue "+e.getMessage());
207
201
  }
208
202
 
209
203
  try {
210
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_EMAIL)) {
211
- Object email = map.get(AppIceReactPluginModule.APPICE_USER_EMAIL);
204
+ if (map.containsKey(Constants.APPICE_USER_EMAIL)) {
205
+ Object email = map.get(Constants.APPICE_USER_EMAIL);
212
206
  if (email != null) {
213
207
  user.setEmail(email.toString());
214
208
  }
215
209
  }
216
210
  } catch (Exception e) {
217
- Log.d(TAG, "setUser: email issue "+e.getMessage());
211
+ AppICEUtils.printLog(TAG, "setUser: email issue "+e.getMessage());
218
212
  }
219
213
 
220
214
  try {
221
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_AGE)) {
222
- Object age = map.get(AppIceReactPluginModule.APPICE_USER_AGE);
215
+ if (map.containsKey(Constants.APPICE_USER_AGE)) {
216
+ Object age = map.get(Constants.APPICE_USER_AGE);
223
217
  if (age != null) {
224
218
  user.setAge((Integer) age);
225
219
  }
226
220
  }
227
221
  } catch (Exception e) {
228
- Log.d(TAG, "setUser: age issue "+e.getMessage());
222
+ AppICEUtils.printLog(TAG, "setUser: age issue "+e.getMessage());
229
223
  }
230
224
 
231
225
  try {
232
- if (map.containsKey(AppIceReactPluginModule.dateOfBirth)) {
233
- Object age = map.get(AppIceReactPluginModule.dateOfBirth);
226
+ if (map.containsKey(Constants.dateOfBirth)) {
227
+ Object age = map.get(Constants.dateOfBirth);
234
228
  if (age != null) {
235
229
  user.setDob((Integer) age);
236
230
  }
237
231
  }
238
232
  } catch (Exception e) {
239
- Log.d(TAG, "setUser: dob issue "+e.getMessage());
233
+ AppICEUtils.printLog(TAG, "setUser: dob issue "+e.getMessage());
240
234
  }
241
235
 
242
236
  try {
243
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_EDUCATION)) {
244
- Object ed = map.get(AppIceReactPluginModule.APPICE_USER_EDUCATION);
237
+ if (map.containsKey(Constants.APPICE_USER_EDUCATION)) {
238
+ Object ed = map.get(Constants.APPICE_USER_EDUCATION);
245
239
  if (ed != null) {
246
240
  user.setEducationType(ed.toString());
247
241
  }
248
242
  }
249
243
  } catch (Exception e) {
250
- Log.d(TAG, "setUser: ed issue "+e.getMessage());
244
+ AppICEUtils.printLog(TAG, "setUser: ed issue "+e.getMessage());
251
245
  }
252
246
 
253
247
  try {
254
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_GENDER)) {
255
- Object g = map.get(AppIceReactPluginModule.APPICE_USER_GENDER);
248
+ if (map.containsKey(Constants.APPICE_USER_GENDER)) {
249
+ Object g = map.get(Constants.APPICE_USER_GENDER);
256
250
  if (g != null) {
257
251
  user.setGender(g.toString());
258
252
  }
259
253
  }
260
254
  } catch (Exception e) {
261
- Log.d(TAG, "setUser: gender issue "+e.getMessage());
255
+ AppICEUtils.printLog(TAG, "setUser: gender issue "+e.getMessage());
262
256
  }
263
257
 
264
258
 
265
259
  try {
266
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_IS_EMPLOYED)) {
267
- Object is_emp = map.get(AppIceReactPluginModule.APPICE_USER_IS_EMPLOYED);
260
+ if (map.containsKey(Constants.APPICE_USER_IS_EMPLOYED)) {
261
+ Object is_emp = map.get(Constants.APPICE_USER_IS_EMPLOYED);
268
262
  if (is_emp != null) {
269
263
  user.setEmployed((Boolean) is_emp);
270
264
  }
271
265
  }
272
266
  } catch (Exception e) {
273
- Log.d(TAG, "setUser: setEmployed issue "+e.getMessage());
267
+ AppICEUtils.printLog(TAG, "setUser: setEmployed issue "+e.getMessage());
274
268
  }
275
269
 
276
270
  try {
277
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_EMPLOYMENT_TYPE)) {
278
- Object et = map.get(AppIceReactPluginModule.APPICE_USER_EMPLOYMENT_TYPE);
271
+ if (map.containsKey(Constants.APPICE_USER_EMPLOYMENT_TYPE)) {
272
+ Object et = map.get(Constants.APPICE_USER_EMPLOYMENT_TYPE);
279
273
  if (et != null) {
280
274
  user.setEmploymentType(et.toString());
281
275
  }
282
276
  }
283
277
  } catch (Exception e) {
284
- Log.d(TAG, "setUser: et issue "+e.getMessage());
278
+ AppICEUtils.printLog(TAG, "setUser: et issue "+e.getMessage());
285
279
  }
286
280
 
287
281
  try {
288
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_MARRIED)) {
289
- Object m = map.get(AppIceReactPluginModule.APPICE_USER_MARRIED);
282
+ if (map.containsKey(Constants.APPICE_USER_MARRIED)) {
283
+ Object m = map.get(Constants.APPICE_USER_MARRIED);
290
284
  if (m != null) {
291
285
  user.setMarried((Boolean) m);
292
286
  }
293
287
  }
294
288
  } catch (Exception e) {
295
- Log.d(TAG, "setUser: married issue "+e.getMessage());
289
+ AppICEUtils.printLog(TAG, "setUser: married issue "+e.getMessage());
296
290
  }
297
291
  ContextSdk.setUser(user, context);
298
292
  } catch (Exception e) {
@@ -317,17 +311,17 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
317
311
  @Override
318
312
  public Map<String, Object> getConstants() {
319
313
  final Map<String, Object> constants = new HashMap<>();
320
- constants.put(APPICE_USER_NAME, APPICE_USER_NAME);
321
- constants.put(APPICE_USER_PHONE, APPICE_USER_PHONE);
322
- constants.put(APPICE_USER_EMAIL, APPICE_USER_EMAIL);
323
- constants.put(APPICE_USER_IS_EMPLOYED, APPICE_USER_IS_EMPLOYED);
324
- constants.put(APPICE_USER_MARRIED, APPICE_USER_MARRIED);
325
- constants.put(APPICE_USER_EDUCATION, APPICE_USER_EDUCATION);
326
- constants.put(APPICE_USER_EMPLOYMENT_TYPE, APPICE_USER_EMPLOYMENT_TYPE);
327
- constants.put(APPICE_USER_AGE, APPICE_USER_AGE);
328
- constants.put(APPICE_USER_GENDER, APPICE_USER_GENDER);
329
- constants.put(APPICE_PUSH_NOTIFICATION_CLICKED, APPICE_PUSH_NOTIFICATION_CLICKED);
330
- constants.put(APPICE_INAPP_NOTIFICATION_CLICKED, APPICE_INAPP_NOTIFICATION_CLICKED);
314
+ constants.put(Constants.APPICE_USER_NAME, Constants.APPICE_USER_NAME);
315
+ constants.put(Constants.APPICE_USER_PHONE, Constants.APPICE_USER_PHONE);
316
+ constants.put(Constants.APPICE_USER_EMAIL, Constants.APPICE_USER_EMAIL);
317
+ constants.put(Constants.APPICE_USER_IS_EMPLOYED, Constants.APPICE_USER_IS_EMPLOYED);
318
+ constants.put(Constants.APPICE_USER_MARRIED, Constants.APPICE_USER_MARRIED);
319
+ constants.put(Constants.APPICE_USER_EDUCATION, Constants.APPICE_USER_EDUCATION);
320
+ constants.put(Constants.APPICE_USER_EMPLOYMENT_TYPE, Constants.APPICE_USER_EMPLOYMENT_TYPE);
321
+ constants.put(Constants.APPICE_USER_AGE, Constants.APPICE_USER_AGE);
322
+ constants.put(Constants.APPICE_USER_GENDER, Constants.APPICE_USER_GENDER);
323
+ constants.put(Constants.APPICE_PUSH_NOTIFICATION_CLICKED, Constants.APPICE_PUSH_NOTIFICATION_CLICKED);
324
+ constants.put(Constants.APPICE_INAPP_NOTIFICATION_CLICKED, Constants.APPICE_INAPP_NOTIFICATION_CLICKED);
331
325
  return constants;
332
326
  }
333
327
 
@@ -341,13 +335,137 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
341
335
  // Remove upstream listeners, stop unnecessary background tasks
342
336
  }
343
337
 
338
+ //==============================================
339
+ // notification
340
+ //==============================================
344
341
  @ReactMethod
345
342
  public void pushNotificationClicked(String payload) {
346
343
  Context ctx = getReactApplicationContext();
347
344
  ContextSdk.pushNotificationClicked(payload, ctx);
348
345
  }
349
346
 
347
+ //========================================
348
+ // AppInbox
349
+ //=========================================
350
+
351
+ /**
352
+ * Get inbox messages list.
353
+ *
354
+ * @param type the message type
355
+ * 1 = ALL
356
+ * 2 = UNREAD
357
+ * 3 = READ
358
+ * 4 = VIEWED
359
+ * 5 = DELETED
360
+ * @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
361
+ * @callback will have the string json array
362
+ */
363
+ @ReactMethod
364
+ public void getInboxMessages(int type, ReadableArray userIds, Callback callback ){
365
+ Context context = getReactApplicationContext();
366
+ WritableArray writableArray = Arguments.createArray();
367
+ try {
368
+ ArrayList<String> finalValues = arrayListStringFromReadableArray(userIds);
369
+ if (finalValues != null) {
370
+ String[] usersId = finalValues.toArray(new String[finalValues.size()]);
371
+ List<AppICEInboxMessage> appICEInboxMessage = ContextSdk.getInboxMessage(type, usersId, context);
372
+ for (int i = 0; i < appICEInboxMessage.size(); i++) {
373
+ AppICEInboxMessage inboxMessage = appICEInboxMessage.get(i);
374
+ writableArray.pushMap(AppICEUtils.convertClassToWritableMap(inboxMessage));
375
+ }
376
+ }
377
+ callback.invoke(writableArray);
378
+ } catch (Throwable e) {
379
+ callback.invoke(e);
380
+ }
381
+ }
382
+
383
+ /**
384
+ * Get inbox messages count.
385
+ *
386
+ * @param type the message type
387
+ * 1 = ALL
388
+ * 2 = UNREAD
389
+ * 3 = READ
390
+ * 4 = VIEWED
391
+ * 5 = DELETED
392
+ * @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
393
+ * @callback will have the integer
394
+ */
395
+ @ReactMethod
396
+ public void getMessageCount(int type, ReadableArray userIds, Callback callback ){
397
+ Context context = getReactApplicationContext();
398
+ int count = 0;
399
+ try {
400
+ ArrayList<String> finalValues = arrayListStringFromReadableArray(userIds);
401
+ if (finalValues != null) {
402
+ String[] usersId = finalValues.toArray(new String[finalValues.size()]);
403
+ count = ContextSdk.getMessageCount(type, usersId, context);
404
+ }
405
+ callback.invoke(count);
406
+ } catch (Throwable e) {
407
+ callback.invoke(e);
408
+ }
409
+ }
410
+
411
+ /**
412
+ * Get messages payload based on message id.
413
+ *
414
+ * @param messageId - message id of the notification
415
+ * @param userId - single userid in string ie. "useridA"
416
+ * @callback will have the json object
417
+ */
418
+ @ReactMethod
419
+ public void getInboxMessageForId(String messageId, String userId, Callback callback ){
420
+ Context context = getReactApplicationContext();
421
+ try {
422
+ AppICEInboxMessage inboxMessage = ContextSdk.getInboxMessageForId(messageId, userId, context);
423
+ callback.invoke(AppICEUtils.convertClassToWritableMap(inboxMessage));
424
+ } catch (Throwable e) {
425
+ callback.invoke(e);
426
+ }
427
+ }
428
+
429
+ /**
430
+ * update message status ex. UNREAD to READ.
431
+ *
432
+ * @param messageId - message id of the notification
433
+ * @param type - integer value for status
434
+ * @param userId - single userid in string
435
+ * @callback will have the boolean
436
+ */
437
+ @ReactMethod
438
+ public void updateInboxMessage(String messageId, int type, String userId, Callback callback ){
439
+ Context context = getReactApplicationContext();
440
+ try {
441
+ boolean isUpdated = ContextSdk.updatedInboxMessage(messageId, type, userId, context);
442
+ callback.invoke(isUpdated);
443
+ } catch (Throwable e) {
444
+ callback.invoke(e);
445
+ }
446
+ }
447
+
350
448
 
449
+ /**
450
+ * To sync with server if server will have any new data to update.
451
+ *
452
+ * @param timeout - integer value for status
453
+ * @callback will have the boolean
454
+ */
455
+ @ReactMethod
456
+ public void synchronizeInbox(int timeout, Callback callback ){
457
+ Context context = getReactApplicationContext();
458
+ try {
459
+ ContextSdk.synchronizeInbox(new IAppICESuccessCallback() {
460
+ @Override
461
+ public void callback(boolean isAppInboxRefreshed) {
462
+ callback.invoke(isAppInboxRefreshed);
463
+ }
464
+ }, timeout, context);
465
+ } catch (Throwable e) {
466
+ callback.invoke(e);
467
+ }
468
+ }
351
469
 
352
470
  //===========================================
353
471
  // Device Setting
@@ -376,7 +494,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
376
494
  callback.invoke(ContextSdk.getInternalId(context));
377
495
  }
378
496
 
379
-
497
+ //=====================================
380
498
  public static void sendEvent(String eventName, @Nullable WritableMap params) {
381
499
  try {
382
500
  context.
@@ -386,118 +504,4 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
386
504
  Log.e(TAG, "java.lang.RuntimeException: Trying to invoke JS before CatalystInstance has been set!", e);
387
505
  }
388
506
  }
389
-
390
- private static ArrayList<String> arrayListStringFromReadableArray(ReadableArray readableArray) {
391
- ArrayList<String> array = new ArrayList<>();
392
- for (int i = 0; i < readableArray.size(); i++) {
393
- switch (readableArray.getType(i)) {
394
- case Null:
395
- break;
396
- case Boolean:
397
- array.add(String.valueOf(readableArray.getBoolean(i)));
398
- break;
399
- case Number:
400
- array.add(String.valueOf(readableArray.getDouble(i)));
401
- break;
402
- case String:
403
- array.add(readableArray.getString(i));
404
- break;
405
- }
406
- }
407
- return array;
408
- }
409
-
410
- private static JSONArray jsonArrayFromReadableArray(ReadableArray readableArray) throws JSONException {
411
- JSONArray array = new JSONArray();
412
- for (int i = 0; i < readableArray.size(); i++) {
413
- switch (readableArray.getType(i)) {
414
- case Null:
415
- break;
416
- case Boolean:
417
- array.put(readableArray.getBoolean(i));
418
- break;
419
- case Number:
420
- array.put(readableArray.getDouble(i));
421
- break;
422
- case String:
423
- array.put(readableArray.getString(i));
424
- break;
425
- case Map:
426
- array.put(jsonObjectFromReadableMap(readableArray.getMap(i)));
427
- break;
428
- case Array:
429
- array.put(jsonArrayFromReadableArray(readableArray.getArray(i)));
430
- break;
431
- }
432
- }
433
- return array;
434
- }
435
-
436
- private static JSONObject jsonObjectFromReadableMap(ReadableMap readableMap) throws JSONException {
437
- JSONObject object = new JSONObject();
438
- ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
439
- while (iterator.hasNextKey()) {
440
- String key = iterator.nextKey();
441
- switch (readableMap.getType(key)) {
442
- case Null:
443
- object.put(key, JSONObject.NULL);
444
- break;
445
- case Boolean:
446
- object.put(key, readableMap.getBoolean(key));
447
- break;
448
- case Number:
449
- object.put(key, readableMap.getDouble(key));
450
- break;
451
- case String:
452
- object.put(key, readableMap.getString(key));
453
- break;
454
- case Map:
455
- object.put(key, jsonObjectFromReadableMap(readableMap.getMap(key)));
456
- break;
457
- case Array:
458
- object.put(key, jsonArrayFromReadableArray(readableMap.getArray(key)));
459
- break;
460
- }
461
- }
462
- return object;
463
- }
464
-
465
- /**
466
- * @param propsMap took data from js and iterate it and store in hashmap
467
- * @return map of the props data
468
- */
469
- private HashMap<String, Object> eventPropsFromReadableMap(ReadableMap propsMap) {
470
- if (propsMap == null) return null;
471
-
472
- HashMap<String, Object> props = new HashMap<>();
473
- ReadableMapKeySetIterator iterator = propsMap.keySetIterator();
474
-
475
- while (iterator.hasNextKey()) {
476
- try {
477
- String key = iterator.nextKey();
478
- ReadableType readableType = propsMap.getType(key);
479
-
480
- if (readableType == ReadableType.String) {
481
- props.put(key, propsMap.getString(key));
482
- } else if (readableType == ReadableType.Boolean) {
483
- props.put(key, propsMap.getBoolean(key));
484
- } else if (readableType == ReadableType.Number) {
485
- try {
486
- props.put(key, propsMap.getDouble(key));
487
- } catch (Throwable t) {
488
- try {
489
- props.put(key, propsMap.getInt(key));
490
- } catch (Throwable t1) {
491
- Log.d(TAG, "Unhandled ReadableType.Number from ReadableMap");
492
- }
493
- }
494
- } else {
495
- Log.d(TAG, "Unhandled event property ReadableType");
496
- }
497
- } catch (Throwable t) {
498
- Log.d(TAG, t.getLocalizedMessage());
499
- }
500
- }
501
- return props;
502
- }
503
507
  }
@@ -24,12 +24,6 @@ import semusi.activitysdk.ContextSdk;
24
24
 
25
25
  public class CampaignCampsReceiver extends BroadcastReceiver {
26
26
  private static final String TAG = "CampaignCampsReceiver";
27
-
28
- public static ClickCallback clickCallback;
29
-
30
- public CampaignCampsReceiver(ClickCallback clickCallback){
31
- this.clickCallback = clickCallback;
32
- }
33
27
  public CampaignCampsReceiver(){
34
28
  }
35
29
 
@@ -38,6 +32,7 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
38
32
  try {
39
33
  sendCallback(intent.getExtras(), context);
40
34
  } catch (Exception e) {
35
+ AppICEUtils.printLog(TAG,e.getMessage());
41
36
  }
42
37
  }
43
38
 
@@ -51,8 +46,8 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
51
46
  if (category) {
52
47
  if (cdata != null && cdata.length() > 0) {
53
48
  WritableMap params = Arguments.createMap();
54
- params.putString(AppIceReactPluginModule.APPICE_INAPP_NOTIFICATION_CLICKED, cdata);
55
- AppIceReactPluginModule.sendEvent(AppIceReactPluginModule.APPICE_INAPP_NOTIFICATION_CLICKED, params);
49
+ params.putString(Constants.APPICE_INAPP_NOTIFICATION_CLICKED, cdata);
50
+ AppIceReactPluginModule.sendEvent(Constants.APPICE_INAPP_NOTIFICATION_CLICKED, params);
56
51
  }
57
52
  }
58
53
 
@@ -61,13 +56,13 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
61
56
  if (pushContent != null){
62
57
  WritableMap params = Arguments.createMap();
63
58
  if (pushContent != null){
64
- params.putString(AppIceReactPluginModule.APPICE_PUSH_NOTIFICATION_CLICKED, pushContent.toString());
65
- AppIceReactPluginModule.sendEvent(AppIceReactPluginModule.APPICE_PUSH_NOTIFICATION_CLICKED, params);
59
+ params.putString(Constants.APPICE_PUSH_NOTIFICATION_CLICKED, pushContent.toString());
60
+ AppIceReactPluginModule.sendEvent(Constants.APPICE_PUSH_NOTIFICATION_CLICKED, params);
66
61
  }
67
62
  }
68
63
  }
69
64
  } catch (Exception e) {
70
- e.printStackTrace();
65
+ AppICEUtils.printLog(TAG,e.getMessage());
71
66
  }
72
67
  }
73
68
  }
@@ -0,0 +1,42 @@
1
+ package com.reactlibrary;
2
+
3
+ public interface Constants {
4
+
5
+ //=========================
6
+ //USER-PROFILE
7
+ //=========================
8
+ String APPICE_USER_NAME = "n";
9
+ String APPICE_USER_PHONE = "ph";
10
+ String APPICE_USER_EMAIL = "em";
11
+ String dateOfBirth = "dob";
12
+ String APPICE_USER_AGE = "a";
13
+ String APPICE_USER_EDUCATION = "ed";
14
+ String APPICE_USER_GENDER = "g";
15
+ String APPICE_USER_IS_EMPLOYED = "is_emp";
16
+ String APPICE_USER_EMPLOYMENT_TYPE = "et";
17
+ String APPICE_USER_MARRIED = "m";
18
+
19
+ //===========================
20
+ //PUSH
21
+ //============================
22
+ String APPICE_PUSH_NOTIFICATION_CLICKED = "AppICEPushNotificationClicked";
23
+
24
+ //===========================
25
+ //IN-APP
26
+ //============================
27
+ String APPICE_INAPP_NOTIFICATION_CLICKED = "AppICEInAppClicked";
28
+
29
+ //============================
30
+ //INBOX
31
+ //=============================
32
+ String INBOX_MESSAGE = "message";
33
+ String INBOX_TITLE = "title";
34
+ String INBOX_MESSAGE_STATUS = "messageStatus";
35
+ String INBOX_CAMPAIGN_TYPE = "campType";
36
+ String INBOX_MESSAGE_LANGUAGE = "messageLanguage";
37
+ String INBOX_MESSAGE_ID = "id";
38
+ String INBOX_CAMPAIGN_ID = "campId";
39
+ String INBOX_MESSAGE_CATEGORY = "category";
40
+ String INBOX_MESSAGE_ICON = "icon";
41
+ String INBOX_CUSTOM_DATA = "cdata";
42
+ }