react-native-notifyvisitors 4.1.1 → 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.1.1";
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";
@@ -51,92 +55,84 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
51
55
  Callback eventCallback;
52
56
  Callback commonCallback;
53
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;
54
63
 
64
+ Activity mActivity;
65
+ JSONObject mTokens;
66
+ JSONObject mCustomObjects;
67
+ NVCenterStyleConfig config;
68
+
69
+
70
+ /* constructor */
55
71
  public RNNotifyvisitorsModule(ReactApplicationContext reactContext) {
56
72
  super(reactContext);
57
73
  this.reactContext = reactContext;
58
74
  reactContext.addActivityEventListener(this);
59
75
  }
60
76
 
77
+ /* Bridge Caller */
61
78
  @Override
62
79
  public String getName() {
63
80
  return "RNNotifyvisitors";
64
81
  }
65
82
 
66
- @ReactMethod
67
- public static void register(Context context) {
68
- try {
69
- Log.i(TAG, "REGISTER !!");
70
- NotifyVisitorsApplication.register((Application) context.getApplicationContext());
71
- } catch (Exception e) {
72
- Log.i(TAG, "REGISTER ERROR : " + e);
73
- }
74
- }
75
83
 
76
- @ReactMethod
77
- public void getLinkInfo() {
84
+ /* React Native Plugin Initialize */
85
+ @Override
86
+ public void initialize() {
87
+ super.initialize();
78
88
  try {
79
- Log.i(TAG, "GET LINK INFO !!");
80
- if(finalData != null){
81
- sendEvent(PUSH_BANNER_CLICK_EVENT, finalData);
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
+ }
82
97
  }
83
98
  } catch (Exception e) {
84
- Log.i(TAG, "GET LINK INFO ERROR : " + e);
99
+ Log.i(TAG, "INITIALIZE ERROR : " + e);
85
100
  }
86
- }
87
101
 
88
102
 
89
- @ReactMethod
90
- public void showNotifications(int dismissValue) {
91
103
  try {
92
- Log.i(TAG, "SHOW NOTIFICATIONS !!");
93
- 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
+ });
94
110
  } catch (Exception e) {
95
- Log.i(TAG, "SHOW NOTIFICATIONS ERROR : " + e);
111
+ Log.i(TAG, "FETCH EVENT SURVEY ERROR : " + e);
96
112
  }
97
- }
98
113
 
99
- @ReactMethod
100
- public void stopNotifications() {
101
- try {
102
- Log.i(TAG, "STOP NOTIFICATIONS !!");
103
- NotifyVisitorsApi.getInstance(reactContext).stopNotification();
104
- } catch (Exception e) {
105
- Log.i(TAG, "STOP NOTIFICATIONS ERROR : " + e);
106
- }
107
114
  }
108
115
 
116
+
117
+ /* 0 - For Native SDK Initialize From Application Class */
109
118
  @ReactMethod
110
- public void stopPushNotifications(String str) {
119
+ public static void register(Context context) {
111
120
  try {
112
- boolean bValue;
113
- Log.i(TAG, "STOP PUSH NOTIFICATIONS !!");
114
-
115
- if (str != null && str != "") {
116
- if (str.equalsIgnoreCase("true")) {
117
- bValue = true;
118
- } else {
119
- bValue = false;
120
- }
121
- Log.i(TAG, "FINAL BOOLEAN VALUE : " + bValue);
122
- NotifyVisitorsApi.getInstance(reactContext).stopPushNotification(bValue);
123
-
124
- } else {
125
- Log.i(TAG, "PARAMETER CAN NOT BE NULL OR EMPTY");
126
- }
127
-
121
+ Log.i(TAG, "REGISTER !!");
122
+ NotifyVisitorsApplication.register((Application) context.getApplicationContext());
128
123
  } catch (Exception e) {
129
- Log.i(TAG, "STOP PUSH NOTIFICATIONS ERROR : " + e);
124
+ Log.i(TAG, "REGISTER ERROR : " + e);
130
125
  }
131
126
  }
132
127
 
128
+ /* 1 - Survey, InApp Banners */
133
129
  @ReactMethod
134
- public void show(ReadableMap tokens, ReadableMap customObjects, String fragmentName, Callback callback) {
130
+ public void show(ReadableMap tokens, ReadableMap customObjects, final String fragmentName, Callback callback) {
135
131
  try {
136
132
  Log.i(TAG, "SHOW !!");
137
133
  showCallback = callback;
138
134
 
139
- JSONObject mTokens = null;
135
+ mTokens = null;
140
136
  try {
141
137
  if (tokens != null) {
142
138
  HashMap<String, Object> temp = tokens.toHashMap();
@@ -146,7 +142,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
146
142
  Log.i(TAG, "TOKENS PARSE ERROR : " + e);
147
143
  }
148
144
 
149
- JSONObject mCustomObjects = null;
145
+ mCustomObjects = null;
150
146
  try {
151
147
  if (customObjects != null) {
152
148
  HashMap<String, Object> temp = customObjects.toHashMap();
@@ -156,13 +152,169 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
156
152
  Log.i(TAG, "CUSTOM-OBJECT PARSE ERROR : " + e);
157
153
  }
158
154
 
159
- Activity activity = reactContext.getCurrentActivity();
160
- 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
+
161
168
  } catch (Exception e) {
162
169
  Log.i(TAG, "SHOW ERROR : " + e);
163
170
  }
164
171
  }
165
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 */
166
318
  @ReactMethod
167
319
  public void event(String eventName, ReadableMap attributes, String ltv, String scope, Callback callback) {
168
320
  try {
@@ -184,51 +336,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
184
336
  }
185
337
  }
186
338
 
187
- @ReactMethod
188
- public void getNotificationDataListener(final Callback callback) {
189
- try {
190
- Log.i(TAG, "GET NOTIFICATION DATA LISTENER !!");
191
- NotifyVisitorsApi.getInstance(reactContext).getNotificationDataListener(new NotificationListDetailsCallback() {
192
- @Override
193
- public void getNotificationData(JSONArray notificationListResponse) {
194
- Log.i(TAG, "RESPONSE : " + notificationListResponse);
195
- callback.invoke(notificationListResponse.toString());
196
- }
197
- }, 0);
198
-
199
- } catch (Exception e) {
200
- Log.i(TAG, "GET NOTIFICATION DATA LISTENER ERROR : " + e);
201
- }
202
- }
203
-
204
- @ReactMethod
205
- public void getNotificationCount(final Callback callback) {
206
- try {
207
- Log.i(TAG, "GET NOTIFICATION COUNT !!");
208
- NotifyVisitorsApi.getInstance(reactContext).getNotificationCount(new NotificationCountInterface() {
209
- @Override
210
- public void getCount(int count) {
211
- Log.i(TAG, "COUNT : " + count);
212
- String strI = String.valueOf(count);
213
- callback.invoke(strI);
214
- }
215
- });
216
- } catch (Exception e) {
217
- Log.i(TAG, "GET NOTIFICATION COUNT ERROR : " + e);
218
- }
219
- }
220
-
221
- @ReactMethod
222
- public void scheduleNotification(String nid, String tag, String time, String title, String message, String url,
223
- String icon) {
224
- try {
225
- Log.i(TAG, "SCHEDULE NOTIFICATION !!");
226
- NotifyVisitorsApi.getInstance(reactContext).scheduleNotification(nid, tag, time, title, message, url, icon);
227
- } catch (Exception e) {
228
- Log.i(TAG, "SCHEDULE NOTIFICATION ERROR : " + e);
229
- }
230
- }
231
-
339
+ /* 4 - Login User */
232
340
  @ReactMethod
233
341
  public void userIdentifier(String userID, ReadableMap attributes) {
234
342
  try {
@@ -246,60 +354,32 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
246
354
  }
247
355
  }
248
356
 
357
+ /* 5 - chatBot */
249
358
  @ReactMethod
250
- public void stopGeofencePushforDateTime(String dateTime, String additionalHours) {
251
- try {
252
- Log.i(TAG, "STOP GEOFENCE PUSH FOR DATE TIME !!");
253
- int jAdditionalHours = 0;
254
- boolean lock = true;
255
- if (dateTime == null || dateTime.length() == 0) {
256
- Log.i(TAG, "DATETIME CAN NOT BE NULL OR EMPTY");
257
- lock = false;
258
- }
259
-
260
- if (additionalHours == null || additionalHours.length() == 0) {
261
- jAdditionalHours = 0;
262
- } else {
263
- jAdditionalHours = Integer.parseInt(additionalHours);
264
- }
265
-
266
- if (lock) {
267
- NotifyVisitorsApi.getInstance(reactContext).stopGeofencePushforDateTime(dateTime, jAdditionalHours);
268
- lock = true;
269
- }
270
-
271
- } catch (Exception e) {
272
- Log.i(TAG, "STOP GEOFENCE PUSH FOR DATE TIME ERROR : " + e);
273
- }
274
-
275
- }
276
-
277
- @ReactMethod
278
- public void setAutoStartPermission() {
279
- try {
280
- Log.i(TAG, "SET AUTOSTART PERMISSION !!");
281
- Activity activity = getCurrentActivity();
282
- NotifyVisitorsApi.getInstance(reactContext).setAutoStartPermission(activity);
283
- } catch (Exception e) {
284
- Log.i(TAG, "SET AUTOSTART PERMISSION ERROR : " + e);
285
- }
286
- }
287
-
288
- @ReactMethod
289
- public void startChatBot(String screenName) {
359
+ public void startChatBot(final String screenName) {
290
360
  try {
291
361
  Log.i(TAG, "START CHAT BOT !!");
292
362
  if (screenName == null || screenName.equalsIgnoreCase("empty")) {
293
363
  Log.i(TAG, "SCREEN NAME IS MISSING");
294
364
  } else {
295
- Activity activity = getCurrentActivity();
296
- NotifyVisitorsApi.getInstance(activity).startChatBot(screenName, new OnNotifyBotClickListener() {
297
- @Override
298
- public void onInAppRedirection(JSONObject data) {
299
- String strI = data.toString();
300
- sendEvent(CHAT_BOT_BUTTON_CLICK, strI);
301
- }
302
- });
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
+ }
303
383
  }
304
384
 
305
385
  } catch (Exception e) {
@@ -307,20 +387,11 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
307
387
  }
308
388
  }
309
389
 
390
+ /* 6 - Push Notification Channel */
310
391
  @ReactMethod
311
- public void getNvUID(final Callback callback) {
312
- try {
313
- Log.i(TAG, "GET NV UID !!");
314
- String strI = NotifyVisitorsApi.getInstance(reactContext).getNvUid();
315
- callback.invoke(strI);
316
- } catch (Exception e) {
317
- Log.i(TAG, "GET NV UID ERROR : " + e);
318
- }
319
- }
320
-
321
-
322
- @ReactMethod
323
- 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) {
324
395
  try {
325
396
  Log.i(TAG, "CREATE NOTIFICATION CHANNEL !!");
326
397
 
@@ -374,6 +445,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
374
445
  }
375
446
  }
376
447
 
448
+ /* 7 - Push Notification Channel */
377
449
  @ReactMethod
378
450
  public void deleteNotificationChannel(String chId) {
379
451
  try {
@@ -385,6 +457,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
385
457
  }
386
458
  }
387
459
 
460
+ /* 8 - Push Notification Channel Group */
388
461
  @ReactMethod
389
462
  public void createNotificationChannelGroup(String groupId, String groupName) {
390
463
  try {
@@ -395,6 +468,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
395
468
  }
396
469
  }
397
470
 
471
+ /* 9 - Push Notification Channel Group */
398
472
  @ReactMethod
399
473
  public void deleteNotificationChannelGroup(String groupId) {
400
474
  try {
@@ -405,48 +479,358 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
405
479
  }
406
480
  }
407
481
 
482
+ /* 10 - Unread Push Notification Count */
408
483
  @ReactMethod
409
- 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;
410
494
  try {
411
- Log.i(TAG, "GET EVENT SURVEY INFO !!");
412
- 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
+ }
413
612
  } catch (Exception e) {
414
- Log.i(TAG, "GET EVENT SURVEY INFO ERROR : " + e);
613
+ Log.i(TAG, "NOTIFICATION CENTER COUNT ERROR : " + e);
415
614
  }
416
615
  }
417
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
+ }
418
629
 
419
- @Override
420
- public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
421
- //this.onActivityResult(activity, requestCode, resultCode, data);
422
- Log.i(TAG, "ON ACTIVITY RESULT !!");
630
+ } catch (Exception e) {
631
+ Log.i(TAG, "GET NOTIFICATION CENTER COUNT ERROR : " + e);
632
+ }
423
633
  }
424
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
+ }
425
656
 
426
- @Override
427
- public void initialize() {
428
- 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 !!");
429
666
  try {
430
- Log.i(TAG, "INITIALIZE");
431
- Log.i(TAG, "RN-NV PLUGIN VERSION : " + PLUGIN_VERSION);
432
- Activity currentActivity = getCurrentActivity();
433
- if (currentActivity != null) {
434
- Intent intent = currentActivity.getIntent();
435
- if (intent != null) {
436
- 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());
437
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 !!");
438
737
  }
439
738
  } catch (Exception e) {
440
- 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);
751
+ }
752
+ }
753
+
754
+ /* 19 - Stop Showing Location Push for a custom time */
755
+ @ReactMethod
756
+ public void stopGeofencePushforDateTime(String dateTime, String additionalHours) {
757
+ try {
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
+
777
+ } catch (Exception e) {
778
+ Log.i(TAG, "STOP GEOFENCE PUSH FOR DATE TIME ERROR : " + e);
441
779
  }
442
780
 
781
+ }
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) {
443
788
  try {
444
- fetchEventSurvey(reactContext);
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;
445
802
  } catch (Exception e) {
446
- Log.i(TAG, "FETCHING EVENT SURVEY DATA : " + e);
803
+ Log.i(TAG, "GET EVENT SURVEY INFO ERROR : " + e);
447
804
  }
448
805
  }
449
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 */
450
834
  @Override
451
835
  public void onNewIntent(Intent intent) {
452
836
  try {
@@ -459,7 +843,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
459
843
  }
460
844
  }
461
845
 
462
- /* handleIntent method start */
846
+ /* Process data from intent */
463
847
  private void handleIntent(Intent intent) {
464
848
  Log.i(TAG, "INSIDE HANDLE INTENT !!!!");
465
849
 
@@ -535,9 +919,8 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
535
919
  }
536
920
  }
537
921
  }
538
- /* handleIntent method end */
539
-
540
922
 
923
+ /* Send Event Callback to React Native Page */
541
924
  private void sendEvent(String eventName, String params) {
542
925
  try {
543
926
  reactContext
@@ -548,24 +931,8 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
548
931
  }
549
932
  }
550
933
 
551
- public ReactApplicationContext getReactContext() {
552
- return reactContext;
553
- }
554
-
555
- private void fetchEventSurvey(Context context) {
556
- try {
557
- NotifyVisitorsApi.getInstance(context).getEventResponse(new OnEventTrackListener() {
558
- @Override
559
- public void onResponse(JSONObject jsonObject) {
560
- sendResponse(jsonObject);
561
- }
562
- });
563
- } catch (Exception e) {
564
- Log.i(TAG, "FETCH EVENT SURVEY ERROR : " + e);
565
- }
566
-
567
- }
568
934
 
935
+ /* Process click data from event and InApp Survey */
569
936
  private void sendResponse(JSONObject response) {
570
937
  try {
571
938
  if (response != null) {
@@ -599,7 +966,17 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
599
966
  } catch (Exception e) {
600
967
  Log.i(TAG, "SURVEY SEND RESPONSE ERROR : " + e);
601
968
  }
969
+
970
+
602
971
  }
603
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
+ }
604
981
 
605
982
  }