react-native-notifyvisitors 4.0.9 → 4.1.2

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.
@@ -14,14 +14,18 @@ import com.facebook.react.bridge.Callback;
14
14
  import com.facebook.react.bridge.ReactApplicationContext;
15
15
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
16
16
  import com.facebook.react.bridge.ReactMethod;
17
+ import com.facebook.react.bridge.ReadableArray;
17
18
  import com.facebook.react.bridge.ReadableMap;
18
19
  import com.facebook.react.modules.core.DeviceEventManagerModule;
19
20
  import com.notifyvisitors.notifyvisitors.NotifyVisitorsApi;
20
21
  import com.notifyvisitors.notifyvisitors.NotifyVisitorsApplication;
22
+ import com.notifyvisitors.notifyvisitors.center.NVCenterStyleConfig;
21
23
  import com.notifyvisitors.notifyvisitors.interfaces.NotificationCountInterface;
22
24
  import com.notifyvisitors.notifyvisitors.interfaces.NotificationListDetailsCallback;
25
+ import com.notifyvisitors.notifyvisitors.interfaces.OnCenterCountListener;
23
26
  import com.notifyvisitors.notifyvisitors.interfaces.OnEventTrackListener;
24
27
  import com.notifyvisitors.notifyvisitors.interfaces.OnNotifyBotClickListener;
28
+ import com.notifyvisitors.notifyvisitors.interfaces.OnReviewCompleteListener;
25
29
  import com.notifyvisitors.notifyvisitors.push.NVNotificationChannels;
26
30
 
27
31
  import org.json.JSONArray;
@@ -36,7 +40,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
36
40
 
37
41
  private final ReactApplicationContext reactContext;
38
42
  private static final String TAG = "RN-NotifyVisitors";
39
- private static final String PLUGIN_VERSION = "4.0.9";
43
+ private static final String PLUGIN_VERSION = "4.1.2";
40
44
 
41
45
  private String PUSH_BANNER_CLICK_EVENT = "nv_push_banner_click";
42
46
  private String CHAT_BOT_BUTTON_CLICK = "nv_chat_bot_button_click";
@@ -45,94 +49,90 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
45
49
  private String EVENT_CALLBACK = "nv_event_callback";
46
50
  private String COMMON_SHOW_EVENT_CALLBACK = "nv_common_show_event_callback";
47
51
 
52
+ String finalData;
48
53
 
49
54
  Callback showCallback;
50
55
  Callback eventCallback;
51
56
  Callback commonCallback;
52
57
 
58
+ private String tab1Label, tab1Name;
59
+ private String tab2Label, tab2Name;
60
+ private String tab3Label, tab3Name;
61
+ private String selectedTabColor, unSelectedTabColor, selectedTabIndicatorColor;
62
+ private int selectedTabIndex;
53
63
 
64
+ Activity mActivity;
65
+ JSONObject mTokens;
66
+ JSONObject mCustomObjects;
67
+ NVCenterStyleConfig config;
68
+
69
+
70
+ /* constructor */
54
71
  public RNNotifyvisitorsModule(ReactApplicationContext reactContext) {
55
72
  super(reactContext);
56
73
  this.reactContext = reactContext;
57
74
  reactContext.addActivityEventListener(this);
58
75
  }
59
76
 
77
+ /* Bridge Caller */
60
78
  @Override
61
79
  public String getName() {
62
80
  return "RNNotifyvisitors";
63
81
  }
64
82
 
65
- @ReactMethod
66
- public static void register(Context context) {
67
- try {
68
- Log.i(TAG, "REGISTER !!");
69
- NotifyVisitorsApplication.register((Application) context.getApplicationContext());
70
- } catch (Exception e) {
71
- Log.i(TAG, "REGISTER ERROR : " + e);
72
- }
73
- }
74
83
 
75
- @ReactMethod
76
- public void getLinkInfo() {
84
+ /* React Native Plugin Initialize */
85
+ @Override
86
+ public void initialize() {
87
+ super.initialize();
77
88
  try {
78
- Log.i(TAG, "GET LINK INFO !!");
89
+ Log.i(TAG, "INITIALIZE");
90
+ Log.i(TAG, "RN-NV PLUGIN VERSION : " + PLUGIN_VERSION);
91
+ Activity currentActivity = getCurrentActivity();
92
+ if (currentActivity != null) {
93
+ Intent intent = currentActivity.getIntent();
94
+ if (intent != null) {
95
+ handleIntent(intent);
96
+ }
97
+ }
79
98
  } catch (Exception e) {
80
- Log.i(TAG, "GET LINK INFO ERROR : " + e);
99
+ Log.i(TAG, "INITIALIZE ERROR : " + e);
81
100
  }
82
- }
83
101
 
84
102
 
85
- @ReactMethod
86
- public void showNotifications(int dismissValue) {
87
103
  try {
88
- Log.i(TAG, "SHOW NOTIFICATIONS !!");
89
- NotifyVisitorsApi.getInstance(reactContext).showNotifications(dismissValue);
104
+ NotifyVisitorsApi.getInstance(reactContext).getEventResponse(new OnEventTrackListener() {
105
+ @Override
106
+ public void onResponse(JSONObject jsonObject) {
107
+ sendResponse(jsonObject);
108
+ }
109
+ });
90
110
  } catch (Exception e) {
91
- Log.i(TAG, "SHOW NOTIFICATIONS ERROR : " + e);
111
+ Log.i(TAG, "FETCH EVENT SURVEY ERROR : " + e);
92
112
  }
93
- }
94
113
 
95
- @ReactMethod
96
- public void stopNotifications() {
97
- try {
98
- Log.i(TAG, "STOP NOTIFICATIONS !!");
99
- NotifyVisitorsApi.getInstance(reactContext).stopNotification();
100
- } catch (Exception e) {
101
- Log.i(TAG, "STOP NOTIFICATIONS ERROR : " + e);
102
- }
103
114
  }
104
115
 
116
+
117
+ /* 0 - For Native SDK Initialize From Application Class */
105
118
  @ReactMethod
106
- public void stopPushNotifications(String str) {
119
+ public static void register(Context context) {
107
120
  try {
108
- boolean bValue;
109
- Log.i(TAG, "STOP PUSH NOTIFICATIONS !!");
110
-
111
- if (str != null && str != "") {
112
- if (str.equalsIgnoreCase("true")) {
113
- bValue = true;
114
- } else {
115
- bValue = false;
116
- }
117
- Log.i(TAG, "FINAL BOOLEAN VALUE : " + bValue);
118
- NotifyVisitorsApi.getInstance(reactContext).stopPushNotification(bValue);
119
-
120
- } else {
121
- Log.i(TAG, "PARAMETER CAN NOT BE NULL OR EMPTY");
122
- }
123
-
121
+ Log.i(TAG, "REGISTER !!");
122
+ NotifyVisitorsApplication.register((Application) context.getApplicationContext());
124
123
  } catch (Exception e) {
125
- Log.i(TAG, "STOP PUSH NOTIFICATIONS ERROR : " + e);
124
+ Log.i(TAG, "REGISTER ERROR : " + e);
126
125
  }
127
126
  }
128
127
 
128
+ /* 1 - Survey, InApp Banners */
129
129
  @ReactMethod
130
- public void show(ReadableMap tokens, ReadableMap customObjects, String fragmentName, Callback callback) {
130
+ public void show(ReadableMap tokens, ReadableMap customObjects, final String fragmentName, Callback callback) {
131
131
  try {
132
132
  Log.i(TAG, "SHOW !!");
133
133
  showCallback = callback;
134
134
 
135
- JSONObject mTokens = null;
135
+ mTokens = null;
136
136
  try {
137
137
  if (tokens != null) {
138
138
  HashMap<String, Object> temp = tokens.toHashMap();
@@ -142,7 +142,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
142
142
  Log.i(TAG, "TOKENS PARSE ERROR : " + e);
143
143
  }
144
144
 
145
- JSONObject mCustomObjects = null;
145
+ mCustomObjects = null;
146
146
  try {
147
147
  if (customObjects != null) {
148
148
  HashMap<String, Object> temp = customObjects.toHashMap();
@@ -152,13 +152,169 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
152
152
  Log.i(TAG, "CUSTOM-OBJECT PARSE ERROR : " + e);
153
153
  }
154
154
 
155
- Activity activity = reactContext.getCurrentActivity();
156
- NotifyVisitorsApi.getInstance(activity).show(mTokens, mCustomObjects, fragmentName);
155
+ mActivity = reactContext.getCurrentActivity();
156
+ if (mActivity != null) {
157
+ mActivity.runOnUiThread(new Runnable() {
158
+ @Override
159
+ public void run() {
160
+ NotifyVisitorsApi.getInstance(mActivity).show(mTokens, mCustomObjects, fragmentName);
161
+ }
162
+ });
163
+ } else {
164
+ Log.e(TAG, "Getting Null Activity !!");
165
+ }
166
+
167
+
157
168
  } catch (Exception e) {
158
169
  Log.i(TAG, "SHOW ERROR : " + e);
159
170
  }
160
171
  }
161
172
 
173
+ /* 2 - Notification Center */
174
+ @ReactMethod
175
+ public void showNotifications(ReadableMap mAppInboxInfo, final int dismissValue) {
176
+ Log.i(TAG, "SHOW NOTIFICATIONS !!");
177
+
178
+ tab1Label = null;
179
+ tab1Name = null;
180
+ tab2Label = null;
181
+ tab2Name = null;
182
+ tab3Label = null;
183
+ tab3Name = null;
184
+ selectedTabColor = null;
185
+ unSelectedTabColor = null;
186
+ selectedTabIndicatorColor = null;
187
+ selectedTabIndex = 0;
188
+
189
+ JSONObject appInboxInfo;
190
+
191
+
192
+ try {
193
+ if (mAppInboxInfo != null) {
194
+ HashMap<String, Object> temp = mAppInboxInfo.toHashMap();
195
+ appInboxInfo = new JSONObject(temp);
196
+
197
+ try {
198
+ tab1Label = appInboxInfo.getString("label_one");
199
+ } catch (Exception e) {
200
+ Log.i(TAG, "SHOW NOTIFICATIONS TAB1LABEL ERROR :" + e);
201
+ }
202
+
203
+ try {
204
+ tab1Name = appInboxInfo.getString("name_one");
205
+ } catch (Exception e) {
206
+ Log.i(TAG, "SHOW NOTIFICATIONS TAB1NAME ERROR :" + e);
207
+ }
208
+
209
+ try {
210
+ tab2Label = appInboxInfo.getString("label_two");
211
+ } catch (Exception e) {
212
+ Log.i(TAG, "SHOW NOTIFICATIONS TAB2LABEL ERROR :" + e);
213
+ }
214
+
215
+ try {
216
+ tab2Name = appInboxInfo.getString("name_two");
217
+ } catch (Exception e) {
218
+ Log.i(TAG, "SHOW NOTIFICATIONS TAB2NAME ERROR :" + e);
219
+ }
220
+
221
+ try {
222
+ tab3Label = appInboxInfo.getString("label_three");
223
+ } catch (Exception e) {
224
+ Log.i(TAG, "SHOW NOTIFICATIONS TAB3LABEL ERROR :" + e);
225
+ }
226
+
227
+ try {
228
+ tab3Name = appInboxInfo.getString("name_three");
229
+ } catch (Exception e) {
230
+ Log.i(TAG, "SHOW NOTIFICATIONS TAB3NAME ERROR :" + e);
231
+ }
232
+
233
+ try {
234
+ selectedTabColor = appInboxInfo.getString("selectedTabTextColor");
235
+ } catch (Exception e) {
236
+ Log.i(TAG, "SHOW NOTIFICATIONS SELECTED TAB COLOR ERROR :" + e);
237
+ selectedTabColor = "#0000ff";
238
+ }
239
+
240
+ try {
241
+ unSelectedTabColor = appInboxInfo.getString("unselectedTabTextColor");
242
+ } catch (Exception e) {
243
+ Log.i(TAG, "SHOW NOTIFICATIONS UNSELECTED TAB COLOR ERROR :" + e);
244
+ unSelectedTabColor = "#779ecb";
245
+ }
246
+
247
+ try {
248
+ selectedTabIndicatorColor = appInboxInfo.getString("selectedTabBgColor");
249
+ } catch (Exception e) {
250
+ Log.i(TAG, "SHOW NOTIFICATIONS SELECTED TAB INDICATOR COLOR ERROR :" + e);
251
+ selectedTabIndicatorColor = "#0000ff";
252
+ }
253
+
254
+ try {
255
+ selectedTabIndex = appInboxInfo.getInt("selectedTabIndex_ios");
256
+ } catch (Exception e) {
257
+ Log.i(TAG, "SELECTED TAB INDEX ERROR :" + e);
258
+ }
259
+
260
+ if (tab1Label.equalsIgnoreCase("null")) {
261
+ tab1Label = null;
262
+ }
263
+
264
+ if (tab1Name.equalsIgnoreCase("null")) {
265
+ tab1Name = null;
266
+ }
267
+
268
+ if (tab2Label.equalsIgnoreCase("null")) {
269
+ tab2Label = null;
270
+ }
271
+
272
+ if (tab2Name.equalsIgnoreCase("null")) {
273
+ tab2Name = null;
274
+ }
275
+
276
+ if (tab3Label.equalsIgnoreCase("null")) {
277
+ tab3Label = null;
278
+ }
279
+
280
+ if (tab3Name.equalsIgnoreCase("null")) {
281
+ tab3Name = null;
282
+ }
283
+
284
+ config = new NVCenterStyleConfig();
285
+ config.setFirstTabDetail(tab1Label, tab1Name);
286
+ config.setSecondTabDetail(tab2Label, tab2Name);
287
+ config.setThirdTabDetail(tab3Label, tab3Name);
288
+
289
+ config.setSelectedTabColor(selectedTabColor);
290
+ config.setUnSelectedTabColor(unSelectedTabColor);
291
+ config.setSelectedTabIndicatorColor(selectedTabIndicatorColor);
292
+
293
+ Log.e(TAG, config.toString());
294
+ mActivity = reactContext.getCurrentActivity();
295
+ if (mActivity != null) {
296
+ mActivity.runOnUiThread(new Runnable() {
297
+ @Override
298
+ public void run() {
299
+ NotifyVisitorsApi.getInstance(reactContext).showNotifications(dismissValue, config);
300
+ }
301
+ });
302
+ } else {
303
+ Log.e(TAG, "Getting Null Activity !!");
304
+ }
305
+
306
+
307
+ } else {
308
+ Log.i(TAG, "TAB INFO IS NULL !! GOING FOR SIMPLE APP INBOX ");
309
+ NotifyVisitorsApi.getInstance(reactContext).showNotifications(dismissValue, null);
310
+ }
311
+ } catch (Exception e) {
312
+ Log.i(TAG, "SHOW NOTIFICATIONS ERROR : " + e);
313
+ }
314
+
315
+ }
316
+
317
+ /* 3 - Event Tracking */
162
318
  @ReactMethod
163
319
  public void event(String eventName, ReadableMap attributes, String ltv, String scope, Callback callback) {
164
320
  try {
@@ -180,51 +336,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
180
336
  }
181
337
  }
182
338
 
183
- @ReactMethod
184
- public void getNotificationDataListener(final Callback callback) {
185
- try {
186
- Log.i(TAG, "GET NOTIFICATION DATA LISTENER !!");
187
- NotifyVisitorsApi.getInstance(reactContext).getNotificationDataListener(new NotificationListDetailsCallback() {
188
- @Override
189
- public void getNotificationData(JSONArray notificationListResponse) {
190
- Log.i(TAG, "RESPONSE : " + notificationListResponse);
191
- callback.invoke(notificationListResponse.toString());
192
- }
193
- }, 0);
194
-
195
- } catch (Exception e) {
196
- Log.i(TAG, "GET NOTIFICATION DATA LISTENER ERROR : " + e);
197
- }
198
- }
199
-
200
- @ReactMethod
201
- public void getNotificationCount(final Callback callback) {
202
- try {
203
- Log.i(TAG, "GET NOTIFICATION COUNT !!");
204
- NotifyVisitorsApi.getInstance(reactContext).getNotificationCount(new NotificationCountInterface() {
205
- @Override
206
- public void getCount(int count) {
207
- Log.i(TAG, "COUNT : " + count);
208
- String strI = String.valueOf(count);
209
- callback.invoke(strI);
210
- }
211
- });
212
- } catch (Exception e) {
213
- Log.i(TAG, "GET NOTIFICATION COUNT ERROR : " + e);
214
- }
215
- }
216
-
217
- @ReactMethod
218
- public void scheduleNotification(String nid, String tag, String time, String title, String message, String url,
219
- String icon) {
220
- try {
221
- Log.i(TAG, "SCHEDULE NOTIFICATION !!");
222
- NotifyVisitorsApi.getInstance(reactContext).scheduleNotification(nid, tag, time, title, message, url, icon);
223
- } catch (Exception e) {
224
- Log.i(TAG, "SCHEDULE NOTIFICATION ERROR : " + e);
225
- }
226
- }
227
-
339
+ /* 4 - Login User */
228
340
  @ReactMethod
229
341
  public void userIdentifier(String userID, ReadableMap attributes) {
230
342
  try {
@@ -242,60 +354,32 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
242
354
  }
243
355
  }
244
356
 
357
+ /* 5 - chatBot */
245
358
  @ReactMethod
246
- public void stopGeofencePushforDateTime(String dateTime, String additionalHours) {
247
- try {
248
- Log.i(TAG, "STOP GEOFENCE PUSH FOR DATE TIME !!");
249
- int jAdditionalHours = 0;
250
- boolean lock = true;
251
- if (dateTime == null || dateTime.length() == 0) {
252
- Log.i(TAG, "DATETIME CAN NOT BE NULL OR EMPTY");
253
- lock = false;
254
- }
255
-
256
- if (additionalHours == null || additionalHours.length() == 0) {
257
- jAdditionalHours = 0;
258
- } else {
259
- jAdditionalHours = Integer.parseInt(additionalHours);
260
- }
261
-
262
- if (lock) {
263
- NotifyVisitorsApi.getInstance(reactContext).stopGeofencePushforDateTime(dateTime, jAdditionalHours);
264
- lock = true;
265
- }
266
-
267
- } catch (Exception e) {
268
- Log.i(TAG, "STOP GEOFENCE PUSH FOR DATE TIME ERROR : " + e);
269
- }
270
-
271
- }
272
-
273
- @ReactMethod
274
- public void setAutoStartPermission() {
275
- try {
276
- Log.i(TAG, "SET AUTOSTART PERMISSION !!");
277
- Activity activity = getCurrentActivity();
278
- NotifyVisitorsApi.getInstance(reactContext).setAutoStartPermission(activity);
279
- } catch (Exception e) {
280
- Log.i(TAG, "SET AUTOSTART PERMISSION ERROR : " + e);
281
- }
282
- }
283
-
284
- @ReactMethod
285
- public void startChatBot(String screenName) {
359
+ public void startChatBot(final String screenName) {
286
360
  try {
287
361
  Log.i(TAG, "START CHAT BOT !!");
288
362
  if (screenName == null || screenName.equalsIgnoreCase("empty")) {
289
363
  Log.i(TAG, "SCREEN NAME IS MISSING");
290
364
  } else {
291
- Activity activity = getCurrentActivity();
292
- NotifyVisitorsApi.getInstance(activity).startChatBot(screenName, new OnNotifyBotClickListener() {
293
- @Override
294
- public void onInAppRedirection(JSONObject data) {
295
- String strI = data.toString();
296
- sendEvent(CHAT_BOT_BUTTON_CLICK, strI);
297
- }
298
- });
365
+ mActivity = getCurrentActivity();
366
+ mActivity = reactContext.getCurrentActivity();
367
+ if (mActivity != null) {
368
+ mActivity.runOnUiThread(new Runnable() {
369
+ @Override
370
+ public void run() {
371
+ NotifyVisitorsApi.getInstance(mActivity).startChatBot(screenName, new OnNotifyBotClickListener() {
372
+ @Override
373
+ public void onInAppRedirection(JSONObject data) {
374
+ String strI = data.toString();
375
+ sendEvent(CHAT_BOT_BUTTON_CLICK, strI);
376
+ }
377
+ });
378
+ }
379
+ });
380
+ } else {
381
+ Log.e(TAG, "Getting Null Activity !!");
382
+ }
299
383
  }
300
384
 
301
385
  } catch (Exception e) {
@@ -303,20 +387,11 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
303
387
  }
304
388
  }
305
389
 
390
+ /* 6 - Push Notification Channel */
306
391
  @ReactMethod
307
- public void getNvUID(final Callback callback) {
308
- try {
309
- Log.i(TAG, "GET NV UID !!");
310
- String strI = NotifyVisitorsApi.getInstance(reactContext).getNvUid();
311
- callback.invoke(strI);
312
- } catch (Exception e) {
313
- Log.i(TAG, "GET NV UID ERROR : " + e);
314
- }
315
- }
316
-
317
-
318
- @ReactMethod
319
- public void createNotificationChannel(String chId, String chName, String chDescription, String chImportance, String enableLights, String shouldVibrate, String lightColor, String soundFileName) {
392
+ public void createNotificationChannel(String chId, String chName, String chDescription,
393
+ String chImportance, String enableLights, String shouldVibrate,
394
+ String lightColor, String soundFileName) {
320
395
  try {
321
396
  Log.i(TAG, "CREATE NOTIFICATION CHANNEL !!");
322
397
 
@@ -370,6 +445,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
370
445
  }
371
446
  }
372
447
 
448
+ /* 7 - Push Notification Channel */
373
449
  @ReactMethod
374
450
  public void deleteNotificationChannel(String chId) {
375
451
  try {
@@ -381,6 +457,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
381
457
  }
382
458
  }
383
459
 
460
+ /* 8 - Push Notification Channel Group */
384
461
  @ReactMethod
385
462
  public void createNotificationChannelGroup(String groupId, String groupName) {
386
463
  try {
@@ -391,6 +468,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
391
468
  }
392
469
  }
393
470
 
471
+ /* 9 - Push Notification Channel Group */
394
472
  @ReactMethod
395
473
  public void deleteNotificationChannelGroup(String groupId) {
396
474
  try {
@@ -401,48 +479,358 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
401
479
  }
402
480
  }
403
481
 
482
+ /* 10 - Unread Push Notification Count */
404
483
  @ReactMethod
405
- public void getEventSurveyInfo(Callback callback) {
484
+ public void getNotificationCenterCount(ReadableMap tabCountInfo, final Callback callback) {
485
+ Log.i(TAG, "GET NOTIFICATION CENTER COUNT !!");
486
+ tab1Label = null;
487
+ tab1Name = null;
488
+ tab2Label = null;
489
+ tab2Name = null;
490
+ tab3Label = null;
491
+ tab3Name = null;
492
+
493
+ JSONObject appInboxInfo;
406
494
  try {
407
- Log.i(TAG, "GET EVENT SURVEY INFO !!");
408
- commonCallback = callback;
495
+ if (tabCountInfo != null) {
496
+ HashMap<String, Object> temp = tabCountInfo.toHashMap();
497
+ appInboxInfo = new JSONObject(temp);
498
+
499
+ try {
500
+ tab1Label = appInboxInfo.getString("label_one");
501
+ } catch (Exception e) {
502
+ Log.i(TAG, "SHOW NOTIFICATIONS TAB1LABEL ERROR :" + e);
503
+ }
504
+
505
+ try {
506
+ tab1Name = appInboxInfo.getString("name_one");
507
+ } catch (Exception e) {
508
+ Log.i(TAG, "SHOW NOTIFICATIONS TAB1NAME ERROR :" + e);
509
+ }
510
+
511
+ try {
512
+ tab2Label = appInboxInfo.getString("label_two");
513
+ } catch (Exception e) {
514
+ Log.i(TAG, "SHOW NOTIFICATIONS TAB2LABEL ERROR :" + e);
515
+ }
516
+
517
+ try {
518
+ tab2Name = appInboxInfo.getString("name_two");
519
+ } catch (Exception e) {
520
+ Log.i(TAG, "SHOW NOTIFICATIONS TAB2NAME ERROR :" + e);
521
+ }
522
+
523
+ try {
524
+ tab3Label = appInboxInfo.getString("label_three");
525
+ } catch (Exception e) {
526
+ Log.i(TAG, "SHOW NOTIFICATIONS TAB3LABEL ERROR :" + e);
527
+ }
528
+
529
+ try {
530
+ tab3Name = appInboxInfo.getString("name_three");
531
+ } catch (Exception e) {
532
+ Log.i(TAG, "SHOW NOTIFICATIONS TAB3NAME ERROR :" + e);
533
+ }
534
+
535
+
536
+ if (tab1Label.equalsIgnoreCase("null")) {
537
+ tab1Label = null;
538
+ }
539
+
540
+ if (tab1Name.equalsIgnoreCase("null")) {
541
+ tab1Name = null;
542
+ }
543
+
544
+ if (tab2Label.equalsIgnoreCase("null")) {
545
+ tab2Label = null;
546
+ }
547
+
548
+ if (tab2Name.equalsIgnoreCase("null")) {
549
+ tab2Name = null;
550
+ }
551
+
552
+ if (tab3Label.equalsIgnoreCase("null")) {
553
+ tab3Label = null;
554
+ }
555
+
556
+ if (tab3Name.equalsIgnoreCase("null")) {
557
+ tab3Name = null;
558
+ }
559
+
560
+ final NVCenterStyleConfig config = new NVCenterStyleConfig();
561
+ config.setFirstTabDetail(tab1Label, tab1Name);
562
+ config.setSecondTabDetail(tab2Label, tab2Name);
563
+ config.setThirdTabDetail(tab3Label, tab3Name);
564
+
565
+
566
+ mActivity = reactContext.getCurrentActivity();
567
+ if (mActivity != null) {
568
+ mActivity.runOnUiThread(new Runnable() {
569
+ @Override
570
+ public void run() {
571
+ NotifyVisitorsApi.getInstance(reactContext).getNotificationCenterCount(new OnCenterCountListener() {
572
+ @Override
573
+ public void getCount(JSONObject tabCount) {
574
+ Log.i(TAG, "Tab Counts : " + tabCount);
575
+ if (tabCount != null) {
576
+ callback.invoke(tabCount.toString());
577
+ } else {
578
+ Log.i(TAG, "GETTING NULL COUNT OBJECT !!");
579
+ }
580
+ }
581
+ }, config);
582
+ }
583
+ });
584
+ } else {
585
+ Log.e(TAG, "Getting Null Activity !!");
586
+ }
587
+
588
+ } else {
589
+ Log.i(TAG, "INFO IS NULL GOING FOR STANDARD NOTIFICATION CENTER COUNT !!");
590
+ mActivity = reactContext.getCurrentActivity();
591
+ if (mActivity != null) {
592
+ mActivity.runOnUiThread(new Runnable() {
593
+ @Override
594
+ public void run() {
595
+ NotifyVisitorsApi.getInstance(reactContext).getNotificationCenterCount(new OnCenterCountListener() {
596
+ @Override
597
+ public void getCount(JSONObject tabCount) {
598
+ Log.i(TAG, "Tab Counts : " + tabCount);
599
+ if (tabCount != null) {
600
+ callback.invoke(tabCount.toString());
601
+ } else {
602
+ Log.i(TAG, "GETTING NULL COUNT OBJECT !!");
603
+ }
604
+ }
605
+ }, null);
606
+ }
607
+ });
608
+ } else {
609
+ Log.e(TAG, "Getting Null Activity !!");
610
+ }
611
+ }
409
612
  } catch (Exception e) {
410
- Log.i(TAG, "GET EVENT SURVEY INFO ERROR : " + e);
613
+ Log.i(TAG, "NOTIFICATION CENTER COUNT ERROR : " + e);
411
614
  }
412
615
  }
413
616
 
617
+ /* 11 - Get FCM/APNS Device Token */
618
+ @ReactMethod
619
+ public void getRegistrationToken(final Callback callback) {
620
+ try {
621
+ Log.i(TAG, "GET NOTIFICATION CENTER COUNT !!");
622
+ JSONObject nv_token = NotifyVisitorsApi.getInstance(reactContext).getPushRegistrationToken();
623
+ if (nv_token != null) {
624
+ String token = nv_token.getString("subscriptionId");
625
+ callback.invoke(token);
626
+ } else {
627
+ callback.invoke("unavailable");
628
+ }
414
629
 
415
- @Override
416
- public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
417
- //this.onActivityResult(activity, requestCode, resultCode, data);
418
- Log.i(TAG, "ON ACTIVITY RESULT !!");
630
+ } catch (Exception e) {
631
+ Log.i(TAG, "GET NOTIFICATION CENTER COUNT ERROR : " + e);
632
+ }
419
633
  }
420
634
 
635
+ /* 12 - Play Store / App Store Rating */
636
+ @ReactMethod
637
+ public void requestInAppReview(final Callback callback) {
638
+ Log.i(TAG, "GOOGLE IN-APP REVIEW !!");
639
+ try {
640
+ mActivity = reactContext.getCurrentActivity();
641
+ if (mActivity != null) {
642
+ mActivity.runOnUiThread(new Runnable() {
643
+ @Override
644
+ public void run() {
645
+ NotifyVisitorsApi.getInstance(mActivity).enableGoogleInAppReview(new OnReviewCompleteListener() {
646
+ @Override
647
+ public void onComplete(String reviewStatus) {
648
+ callback.invoke(reviewStatus);
649
+ }
650
+ });
651
+ }
652
+ });
653
+ } else {
654
+ Log.e(TAG, "Getting Null Activity !!");
655
+ }
421
656
 
422
- @Override
423
- public void initialize() {
424
- super.initialize();
657
+ } catch (Exception e) {
658
+ Log.i(TAG, "GOOGLE IN-APP REVIEW ERROR : " + e);
659
+ }
660
+ }
661
+
662
+ /* 13 - Category based Notification */
663
+ @ReactMethod
664
+ public void subscribePushCategory(ReadableArray categoryInfo, boolean unsubscribeSignal) {
665
+ Log.i(TAG, "SUBSCRIBE PUSH CATEGORY !!");
425
666
  try {
426
- Log.i(TAG, "INITIALIZE");
427
- Log.i(TAG, "RN-NV PLUGIN VERSION : " + PLUGIN_VERSION);
428
- Activity currentActivity = getCurrentActivity();
429
- if (currentActivity != null) {
430
- Intent intent = currentActivity.getIntent();
431
- if (intent != null) {
432
- handleIntent(intent);
667
+ JSONArray mCategoryInfo;
668
+ if (categoryInfo != null) {
669
+ mCategoryInfo = readableArrayToJSONArray(categoryInfo);
670
+ Log.i(TAG, "Category Info :" + mCategoryInfo.toString());
671
+ NotifyVisitorsApi.getInstance(reactContext).pushPreferences(mCategoryInfo, unsubscribeSignal);
672
+ }
673
+ } catch (Exception e) {
674
+ Log.i(TAG, "SUBSCRIBE PUSH CATEGORY ERROR : " + e);
675
+ }
676
+ }
677
+
678
+
679
+ /* 14 - Push /InApp / Notification Center Click Callback Data */
680
+ @ReactMethod
681
+ public void getLinkInfo() {
682
+ try {
683
+ Log.i(TAG, "GET LINK INFO !!");
684
+ if (finalData != null) {
685
+ sendEvent(PUSH_BANNER_CLICK_EVENT, finalData);
686
+ }
687
+ } catch (Exception e) {
688
+ Log.i(TAG, "GET LINK INFO ERROR : " + e);
689
+ }
690
+ }
691
+
692
+ /* 15 - Unique NotifyVisitors Identification */
693
+ @ReactMethod
694
+ public void getNvUID(final Callback callback) {
695
+ try {
696
+ Log.i(TAG, "GET NV UID !!");
697
+ String strI = NotifyVisitorsApi.getInstance(reactContext).getNvUid();
698
+ callback.invoke(strI);
699
+ } catch (Exception e) {
700
+ Log.i(TAG, "GET NV UID ERROR : " + e);
701
+ }
702
+ }
703
+
704
+ /* 16 - JSon Data For Custom Notification Center */
705
+ @ReactMethod
706
+ public void getNotificationDataListener(final Callback callback) {
707
+ try {
708
+ Log.i(TAG, "GET NOTIFICATION DATA LISTENER !!");
709
+ NotifyVisitorsApi.getInstance(reactContext).getNotificationDataListener(new NotificationListDetailsCallback() {
710
+ @Override
711
+ public void getNotificationData(JSONArray notificationListResponse) {
712
+ Log.i(TAG, "RESPONSE : " + notificationListResponse);
713
+ callback.invoke(notificationListResponse.toString());
433
714
  }
715
+ }, 0);
716
+
717
+ } catch (Exception e) {
718
+ Log.i(TAG, "GET NOTIFICATION DATA LISTENER ERROR : " + e);
719
+ }
720
+ }
721
+
722
+ /* 17 - Auto Start Library Android */
723
+ @ReactMethod
724
+ public void setAutoStartPermission() {
725
+ try {
726
+ Log.i(TAG, "SET AUTOSTART PERMISSION !!");
727
+ mActivity = reactContext.getCurrentActivity();
728
+ if (mActivity != null) {
729
+ mActivity.runOnUiThread(new Runnable() {
730
+ @Override
731
+ public void run() {
732
+ NotifyVisitorsApi.getInstance(reactContext).setAutoStartPermission(mActivity);
733
+ }
734
+ });
735
+ } else {
736
+ Log.e(TAG, "Getting Null Activity !!");
434
737
  }
435
738
  } catch (Exception e) {
436
- Log.i(TAG, "INITIALIZE ERROR : " + e);
739
+ Log.i(TAG, "SET AUTOSTART PERMISSION ERROR : " + e);
740
+ }
741
+ }
742
+
743
+ /* 18 - Stop Showing InApp Banner Survey */
744
+ @ReactMethod
745
+ public void stopNotifications() {
746
+ try {
747
+ Log.i(TAG, "STOP NOTIFICATIONS !!");
748
+ NotifyVisitorsApi.getInstance(reactContext).stopNotification();
749
+ } catch (Exception e) {
750
+ Log.i(TAG, "STOP NOTIFICATIONS ERROR : " + e);
437
751
  }
752
+ }
438
753
 
754
+ /* 19 - Stop Showing Location Push for a custom time */
755
+ @ReactMethod
756
+ public void stopGeofencePushforDateTime(String dateTime, String additionalHours) {
439
757
  try {
440
- fetchEventSurvey(reactContext);
758
+ Log.i(TAG, "STOP GEOFENCE PUSH FOR DATE TIME !!");
759
+ int jAdditionalHours = 0;
760
+ boolean lock = true;
761
+ if (dateTime == null || dateTime.length() == 0) {
762
+ Log.i(TAG, "DATETIME CAN NOT BE NULL OR EMPTY");
763
+ lock = false;
764
+ }
765
+
766
+ if (additionalHours == null || additionalHours.length() == 0) {
767
+ jAdditionalHours = 0;
768
+ } else {
769
+ jAdditionalHours = Integer.parseInt(additionalHours);
770
+ }
771
+
772
+ if (lock) {
773
+ NotifyVisitorsApi.getInstance(reactContext).stopGeofencePushforDateTime(dateTime, jAdditionalHours);
774
+ lock = true;
775
+ }
776
+
441
777
  } catch (Exception e) {
442
- Log.i(TAG, "FETCHING EVENT SURVEY DATA : " + e);
778
+ Log.i(TAG, "STOP GEOFENCE PUSH FOR DATE TIME ERROR : " + e);
443
779
  }
780
+
444
781
  }
445
782
 
783
+ /* 20 - Trigger Push Notification on Panel */
784
+ @ReactMethod
785
+ public void scheduleNotification(String nid, String tag, String time,
786
+ String title, String message, String url,
787
+ String icon) {
788
+ try {
789
+ Log.i(TAG, "SCHEDULE NOTIFICATION !!");
790
+ NotifyVisitorsApi.getInstance(reactContext).scheduleNotification(nid, tag, time, title, message, url, icon);
791
+ } catch (Exception e) {
792
+ Log.i(TAG, "SCHEDULE NOTIFICATION ERROR : " + e);
793
+ }
794
+ }
795
+
796
+ /* 21 - Separate Callbacks For Events and Surveys */
797
+ @ReactMethod
798
+ public void getEventSurveyInfo(Callback callback) {
799
+ try {
800
+ Log.i(TAG, "GET EVENT SURVEY INFO !!");
801
+ commonCallback = callback;
802
+ } catch (Exception e) {
803
+ Log.i(TAG, "GET EVENT SURVEY INFO ERROR : " + e);
804
+ }
805
+ }
806
+
807
+ /* 22 - Depricated Function For Notification Count */
808
+ @ReactMethod
809
+ public void getNotificationCount(final Callback callback) {
810
+ try {
811
+ Log.i(TAG, "GET NOTIFICATION COUNT !!");
812
+ NotifyVisitorsApi.getInstance(reactContext).getNotificationCount(new NotificationCountInterface() {
813
+ @Override
814
+ public void getCount(int count) {
815
+ Log.i(TAG, "COUNT : " + count);
816
+ String strI = String.valueOf(count);
817
+ callback.invoke(strI);
818
+ }
819
+ });
820
+ } catch (Exception e) {
821
+ Log.i(TAG, "GET NOTIFICATION COUNT ERROR : " + e);
822
+ }
823
+ }
824
+
825
+
826
+ /* On Activity Result */
827
+ @Override
828
+ public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
829
+ //this.onActivityResult(activity, requestCode, resultCode, data);
830
+ Log.i(TAG, "ON ACTIVITY RESULT !!");
831
+ }
832
+
833
+ /* On New Intents */
446
834
  @Override
447
835
  public void onNewIntent(Intent intent) {
448
836
  try {
@@ -455,12 +843,12 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
455
843
  }
456
844
  }
457
845
 
458
- /* handleIntent method start */
846
+ /* Process data from intent */
459
847
  private void handleIntent(Intent intent) {
460
848
  Log.i(TAG, "INSIDE HANDLE INTENT !!!!");
461
849
 
462
850
  JSONObject dataInfo, finalDataInfo;
463
- String finalData;
851
+
464
852
 
465
853
  String action = intent.getAction();
466
854
  Uri url = intent.getData();
@@ -531,9 +919,8 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
531
919
  }
532
920
  }
533
921
  }
534
- /* handleIntent method end */
535
-
536
922
 
923
+ /* Send Event Callback to React Native Page */
537
924
  private void sendEvent(String eventName, String params) {
538
925
  try {
539
926
  reactContext
@@ -544,24 +931,8 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
544
931
  }
545
932
  }
546
933
 
547
- public ReactApplicationContext getReactContext() {
548
- return reactContext;
549
- }
550
-
551
- private void fetchEventSurvey(Context context) {
552
- try {
553
- NotifyVisitorsApi.getInstance(context).getEventResponse(new OnEventTrackListener() {
554
- @Override
555
- public void onResponse(JSONObject jsonObject) {
556
- sendResponse(jsonObject);
557
- }
558
- });
559
- } catch (Exception e) {
560
- Log.i(TAG, "FETCH EVENT SURVEY ERROR : " + e);
561
- }
562
-
563
- }
564
934
 
935
+ /* Process click data from event and InApp Survey */
565
936
  private void sendResponse(JSONObject response) {
566
937
  try {
567
938
  if (response != null) {
@@ -595,7 +966,17 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
595
966
  } catch (Exception e) {
596
967
  Log.i(TAG, "SURVEY SEND RESPONSE ERROR : " + e);
597
968
  }
969
+
970
+
598
971
  }
599
972
 
973
+ private JSONArray readableArrayToJSONArray(ReadableArray readableArray) {
974
+ JSONArray result = new JSONArray();
975
+ for (int i = 0; i < readableArray.size(); i++) {
976
+ String tmp = readableArray.getString(i);
977
+ result.put(tmp);
978
+ }
979
+ return result;
980
+ }
600
981
 
601
982
  }