react-native-notifyvisitors 4.4.1 → 4.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/.classpath +6 -0
- package/android/.project +6 -0
- package/android/.settings/org.eclipse.buildship.core.prefs +1 -1
- package/android/.settings/org.eclipse.jdt.core.prefs +4 -0
- package/android/bin/.project +34 -0
- package/android/bin/.settings/org.eclipse.buildship.core.prefs +13 -0
- package/android/bin/build.gradle +45 -0
- package/android/bin/src/main/AndroidManifest.xml +24 -0
- package/android/bin/src/main/java/com/rn_notifyvisitors/RNNotifyvisitorsModule.class +0 -0
- package/android/bin/src/main/java/com/rn_notifyvisitors/RNNotifyvisitorsPackage.class +0 -0
- package/android/bin/src/main/res/values/strings.xml +3 -0
- package/android/build.gradle +3 -1
- package/android/src/main/java/com/rn_notifyvisitors/RNNotifyvisitorsModule.java +383 -20
- package/index.d.ts +65 -27
- package/index.js +75 -0
- package/ios/RNNotifyvisitors/RCTNVEventEmitter.m +360 -339
- package/ios/RNNotifyvisitors/RNNotifyvisitors.h +10 -7
- package/ios/RNNotifyvisitors/RNNotifyvisitors.m +35 -1
- package/ios/RNNotifyvisitors.xcodeproj/project.pbxproj +4 -4
- package/ios/notifyvisitors.xcframework/Info.plist +6 -6
- package/ios/notifyvisitors.xcframework/ios-arm64/notifyvisitors.framework/Headers/notifyvisitors.h +46 -16
- package/ios/notifyvisitors.xcframework/ios-arm64/notifyvisitors.framework/Info.plist +0 -0
- package/ios/notifyvisitors.xcframework/ios-arm64/notifyvisitors.framework/_CodeSignature/CodeResources +3 -3
- package/ios/notifyvisitors.xcframework/ios-arm64/notifyvisitors.framework/notifyvisitors +0 -0
- package/ios/notifyvisitors.xcframework/ios-arm64_x86_64-maccatalyst/notifyvisitors.framework/Versions/A/Headers/notifyvisitors.h +46 -16
- package/ios/notifyvisitors.xcframework/ios-arm64_x86_64-maccatalyst/notifyvisitors.framework/Versions/A/Resources/Info.plist +3 -3
- package/ios/notifyvisitors.xcframework/ios-arm64_x86_64-maccatalyst/notifyvisitors.framework/Versions/A/_CodeSignature/CodeResources +3 -3
- package/ios/notifyvisitors.xcframework/ios-arm64_x86_64-maccatalyst/notifyvisitors.framework/Versions/A/notifyvisitors +0 -0
- package/ios/notifyvisitors.xcframework/ios-arm64_x86_64-simulator/notifyvisitors.framework/Headers/notifyvisitors.h +46 -16
- package/ios/notifyvisitors.xcframework/ios-arm64_x86_64-simulator/notifyvisitors.framework/Info.plist +0 -0
- package/ios/notifyvisitors.xcframework/ios-arm64_x86_64-simulator/notifyvisitors.framework/_CodeSignature/CodeResources +3 -3
- package/ios/notifyvisitors.xcframework/ios-arm64_x86_64-simulator/notifyvisitors.framework/notifyvisitors +0 -0
- package/package.json +1 -1
- package/react-native-notifyvisitors.podspec +1 -1
|
@@ -17,6 +17,7 @@ import com.facebook.react.bridge.ReactMethod;
|
|
|
17
17
|
import com.facebook.react.bridge.ReadableArray;
|
|
18
18
|
import com.facebook.react.bridge.ReadableMap;
|
|
19
19
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
20
|
+
|
|
20
21
|
import com.notifyvisitors.notifyvisitors.NotifyVisitorsApi;
|
|
21
22
|
import com.notifyvisitors.notifyvisitors.NotifyVisitorsApplication;
|
|
22
23
|
import com.notifyvisitors.notifyvisitors.center.NVCenterStyleConfig;
|
|
@@ -28,6 +29,10 @@ import com.notifyvisitors.notifyvisitors.interfaces.OnEventTrackListener;
|
|
|
28
29
|
import com.notifyvisitors.notifyvisitors.interfaces.OnPushRuntimePermission;
|
|
29
30
|
import com.notifyvisitors.notifyvisitors.permission.NVPopupDesign;
|
|
30
31
|
import com.notifyvisitors.notifyvisitors.push.NVNotificationChannels;
|
|
32
|
+
import com.notifyvisitors.notifyvisitors.interfaces.OnInAppTriggerListener;
|
|
33
|
+
import com.notifyvisitors.notifyvisitors.interfaces.OnKnownUserFound;
|
|
34
|
+
import com.notifyvisitors.notifyvisitors.interfaces.OnUserTrackListener;
|
|
35
|
+
import com.notifyvisitors.notifyvisitors.interfaces.OnBuildUiListener;
|
|
31
36
|
|
|
32
37
|
import org.json.JSONArray;
|
|
33
38
|
import org.json.JSONObject;
|
|
@@ -37,13 +42,14 @@ import java.util.HashSet;
|
|
|
37
42
|
import java.util.Set;
|
|
38
43
|
import java.util.Timer;
|
|
39
44
|
import java.util.TimerTask;
|
|
45
|
+
import java.util.Iterator;
|
|
40
46
|
|
|
41
47
|
|
|
42
48
|
public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implements ActivityEventListener {
|
|
43
49
|
|
|
44
50
|
private final ReactApplicationContext reactContext;
|
|
45
51
|
private static final String TAG = "RN-NotifyVisitors";
|
|
46
|
-
private static final String PLUGIN_VERSION = "4.4.
|
|
52
|
+
private static final String PLUGIN_VERSION = "4.4.3";
|
|
47
53
|
|
|
48
54
|
private String PUSH_BANNER_CLICK_EVENT = "nv_push_banner_click";
|
|
49
55
|
private String CHAT_BOT_BUTTON_CLICK = "nv_chat_bot_button_click";
|
|
@@ -51,12 +57,16 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
|
|
|
51
57
|
private String SHOW_CALLBACK = "nv_show_callback";
|
|
52
58
|
private String EVENT_CALLBACK = "nv_event_callback";
|
|
53
59
|
private String COMMON_SHOW_EVENT_CALLBACK = "nv_common_show_event_callback";
|
|
60
|
+
private String CENTER_CALLBACK = "nv_center_callback";
|
|
61
|
+
private String KNOWN_USER_IDENTIFIED_CALLBACK = "nv_known_user_identified_callback";
|
|
54
62
|
|
|
55
63
|
String finalData;
|
|
56
64
|
|
|
57
65
|
Callback showCallback;
|
|
58
66
|
Callback eventCallback;
|
|
59
67
|
Callback commonCallback;
|
|
68
|
+
Callback centerCallback;
|
|
69
|
+
Callback onKnownUserIdentifiedCallback;
|
|
60
70
|
|
|
61
71
|
private String tab1Label, tab1Name;
|
|
62
72
|
private String tab2Label, tab2Name;
|
|
@@ -122,7 +132,6 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
|
|
|
122
132
|
|
|
123
133
|
|
|
124
134
|
/* 0 - For Native SDK Initialize From Application Class */
|
|
125
|
-
@ReactMethod
|
|
126
135
|
public static void register(Context context, int brandID, String brandEncryptKey) {
|
|
127
136
|
try {
|
|
128
137
|
Log.i(TAG, "REGISTER !!");
|
|
@@ -213,6 +222,66 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
|
|
|
213
222
|
}
|
|
214
223
|
}
|
|
215
224
|
|
|
225
|
+
@ReactMethod
|
|
226
|
+
public void showInAppMessage(ReadableMap tokens, ReadableMap customObjects, final String fragmentName, Callback callback) {
|
|
227
|
+
try {
|
|
228
|
+
Log.i(TAG, "SHOW IN APP MESSAGE !!");
|
|
229
|
+
showCallback = callback;
|
|
230
|
+
|
|
231
|
+
mTokens = null;
|
|
232
|
+
try {
|
|
233
|
+
if (tokens != null) {
|
|
234
|
+
HashMap<String, Object> temp = tokens.toHashMap();
|
|
235
|
+
mTokens = new JSONObject(temp);
|
|
236
|
+
}
|
|
237
|
+
} catch (Exception e) {
|
|
238
|
+
Log.i(TAG, "TOKENS PARSE ERROR : " + e);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
mCustomObjects = null;
|
|
242
|
+
try {
|
|
243
|
+
if (customObjects != null) {
|
|
244
|
+
HashMap<String, Object> temp = customObjects.toHashMap();
|
|
245
|
+
mCustomObjects = new JSONObject(temp);
|
|
246
|
+
}
|
|
247
|
+
} catch (Exception e) {
|
|
248
|
+
Log.i(TAG, "CUSTOM-OBJECT PARSE ERROR : " + e);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
try {
|
|
252
|
+
if (mTokens != null) {
|
|
253
|
+
Log.i(TAG, "Tokens : " + mTokens.toString());
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (mCustomObjects != null) {
|
|
257
|
+
Log.i(TAG, "Custom Rules : " + mCustomObjects.toString());
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
} catch (Exception e) {
|
|
261
|
+
Log.i(TAG, "ERROR : " + e);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
mActivity = reactContext.getCurrentActivity();
|
|
265
|
+
if (mActivity != null) {
|
|
266
|
+
mActivity.runOnUiThread(new Runnable() {
|
|
267
|
+
@Override
|
|
268
|
+
public void run() {
|
|
269
|
+
NotifyVisitorsApi.getInstance(mActivity).show(mTokens, mCustomObjects, fragmentName, new OnInAppTriggerListener() {
|
|
270
|
+
@Override
|
|
271
|
+
public void onDisplay(JSONObject response) {
|
|
272
|
+
sendEvent(SHOW_CALLBACK, response.toString());
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
} else {
|
|
278
|
+
Log.e(TAG, "Getting Null Activity !!");
|
|
279
|
+
}
|
|
280
|
+
} catch (Exception e) {
|
|
281
|
+
Log.i(TAG, "SHOW ERROR : " + e);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
216
285
|
/* 2 - Notification Center */
|
|
217
286
|
@ReactMethod
|
|
218
287
|
public void showNotifications(ReadableMap mAppInboxInfo, final int dismissValue) {
|
|
@@ -366,6 +435,183 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
|
|
|
366
435
|
|
|
367
436
|
}
|
|
368
437
|
|
|
438
|
+
@ReactMethod
|
|
439
|
+
public void openNotificationCenter(ReadableMap mAppInboxInfo, final int dismissValue, Callback callback) {
|
|
440
|
+
Log.i(TAG, "OPEN NOTIFICATION CENTER !!");
|
|
441
|
+
centerCallback = callback;
|
|
442
|
+
|
|
443
|
+
tab1Label = null;
|
|
444
|
+
tab1Name = null;
|
|
445
|
+
tab2Label = null;
|
|
446
|
+
tab2Name = null;
|
|
447
|
+
tab3Label = null;
|
|
448
|
+
tab3Name = null;
|
|
449
|
+
selectedTabColor = null;
|
|
450
|
+
unSelectedTabColor = null;
|
|
451
|
+
selectedTabIndicatorColor = null;
|
|
452
|
+
selectedTabIndex = 0;
|
|
453
|
+
|
|
454
|
+
JSONObject appInboxInfo;
|
|
455
|
+
|
|
456
|
+
try {
|
|
457
|
+
if (mAppInboxInfo != null) {
|
|
458
|
+
HashMap<String, Object> temp = mAppInboxInfo.toHashMap();
|
|
459
|
+
appInboxInfo = new JSONObject(temp);
|
|
460
|
+
|
|
461
|
+
try {
|
|
462
|
+
tab1Label = appInboxInfo.getString("label_one");
|
|
463
|
+
} catch (Exception e) {
|
|
464
|
+
Log.i(TAG, "SHOW NOTIFICATIONS TAB1LABEL ERROR :" + e);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
try {
|
|
468
|
+
tab1Name = appInboxInfo.getString("name_one");
|
|
469
|
+
} catch (Exception e) {
|
|
470
|
+
Log.i(TAG, "SHOW NOTIFICATIONS TAB1NAME ERROR :" + e);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
try {
|
|
474
|
+
tab2Label = appInboxInfo.getString("label_two");
|
|
475
|
+
} catch (Exception e) {
|
|
476
|
+
Log.i(TAG, "SHOW NOTIFICATIONS TAB2LABEL ERROR :" + e);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
try {
|
|
480
|
+
tab2Name = appInboxInfo.getString("name_two");
|
|
481
|
+
} catch (Exception e) {
|
|
482
|
+
Log.i(TAG, "SHOW NOTIFICATIONS TAB2NAME ERROR :" + e);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
try {
|
|
486
|
+
tab3Label = appInboxInfo.getString("label_three");
|
|
487
|
+
} catch (Exception e) {
|
|
488
|
+
Log.i(TAG, "SHOW NOTIFICATIONS TAB3LABEL ERROR :" + e);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
try {
|
|
492
|
+
tab3Name = appInboxInfo.getString("name_three");
|
|
493
|
+
} catch (Exception e) {
|
|
494
|
+
Log.i(TAG, "SHOW NOTIFICATIONS TAB3NAME ERROR :" + e);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
try {
|
|
498
|
+
selectedTabColor = appInboxInfo.getString("selectedTabTextColor");
|
|
499
|
+
} catch (Exception e) {
|
|
500
|
+
Log.i(TAG, "SHOW NOTIFICATIONS SELECTED TAB COLOR ERROR :" + e);
|
|
501
|
+
selectedTabColor = "#0000ff";
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
try {
|
|
505
|
+
unSelectedTabColor = appInboxInfo.getString("unselectedTabTextColor");
|
|
506
|
+
} catch (Exception e) {
|
|
507
|
+
Log.i(TAG, "SHOW NOTIFICATIONS UNSELECTED TAB COLOR ERROR :" + e);
|
|
508
|
+
unSelectedTabColor = "#779ecb";
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
try {
|
|
512
|
+
selectedTabIndicatorColor = appInboxInfo.getString("selectedTabBgColor");
|
|
513
|
+
} catch (Exception e) {
|
|
514
|
+
Log.i(TAG, "SHOW NOTIFICATIONS SELECTED TAB INDICATOR COLOR ERROR :" + e);
|
|
515
|
+
selectedTabIndicatorColor = "#0000ff";
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
try {
|
|
519
|
+
selectedTabIndex = appInboxInfo.getInt("selectedTabIndex_ios");
|
|
520
|
+
} catch (Exception e) {
|
|
521
|
+
Log.i(TAG, "SELECTED TAB INDEX ERROR :" + e);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
if (tab1Label.equalsIgnoreCase("null")) {
|
|
525
|
+
tab1Label = null;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if (tab1Name.equalsIgnoreCase("null")) {
|
|
529
|
+
tab1Name = null;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
if (tab2Label.equalsIgnoreCase("null")) {
|
|
533
|
+
tab2Label = null;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
if (tab2Name.equalsIgnoreCase("null")) {
|
|
537
|
+
tab2Name = null;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (tab3Label.equalsIgnoreCase("null")) {
|
|
541
|
+
tab3Label = null;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
if (tab3Name.equalsIgnoreCase("null")) {
|
|
545
|
+
tab3Name = null;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
config = new NVCenterStyleConfig();
|
|
549
|
+
config.setFirstTabDetail(tab1Label, tab1Name);
|
|
550
|
+
config.setSecondTabDetail(tab2Label, tab2Name);
|
|
551
|
+
config.setThirdTabDetail(tab3Label, tab3Name);
|
|
552
|
+
|
|
553
|
+
config.setSelectedTabColor(selectedTabColor);
|
|
554
|
+
config.setUnSelectedTabColor(unSelectedTabColor);
|
|
555
|
+
config.setSelectedTabIndicatorColor(selectedTabIndicatorColor);
|
|
556
|
+
|
|
557
|
+
mActivity = reactContext.getCurrentActivity();
|
|
558
|
+
if (mActivity != null) {
|
|
559
|
+
mActivity.runOnUiThread(new Runnable() {
|
|
560
|
+
@Override
|
|
561
|
+
public void run() {
|
|
562
|
+
NotifyVisitorsApi.getInstance(mActivity).showNotifications(dismissValue, config, new OnBuildUiListener() {
|
|
563
|
+
@Override
|
|
564
|
+
public void onCenterClose() {
|
|
565
|
+
//Log.d("App", "Notification center closed");
|
|
566
|
+
try {
|
|
567
|
+
JSONObject j = new JSONObject();
|
|
568
|
+
j.put("status", "success");
|
|
569
|
+
j.put("message", "close button clicked");
|
|
570
|
+
sendResponse(j);
|
|
571
|
+
} catch (Exception e) {
|
|
572
|
+
Log.e(TAG, "CLOSE BUTTON CLICK ERROR :" + e);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
} else {
|
|
579
|
+
Log.e(TAG, "Getting Null Activity !!");
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
} else {
|
|
583
|
+
Log.i(TAG, "TAB INFO IS NULL !! GOING FOR SIMPLE APP INBOX ");
|
|
584
|
+
mActivity = reactContext.getCurrentActivity();
|
|
585
|
+
if (mActivity != null) {
|
|
586
|
+
mActivity.runOnUiThread(new Runnable() {
|
|
587
|
+
@Override
|
|
588
|
+
public void run() {
|
|
589
|
+
NotifyVisitorsApi.getInstance(mActivity).showNotifications(dismissValue, null, new OnBuildUiListener() {
|
|
590
|
+
@Override
|
|
591
|
+
public void onCenterClose() {
|
|
592
|
+
//Log.d("App", "Notification center closed");
|
|
593
|
+
try {
|
|
594
|
+
JSONObject j = new JSONObject();
|
|
595
|
+
j.put("status", "success");
|
|
596
|
+
j.put("message", "close button clicked");
|
|
597
|
+
sendResponse(j);
|
|
598
|
+
} catch (Exception e) {
|
|
599
|
+
Log.e(TAG, "CLOSE BUTTON CLICK ERROR :" + e);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
} else {
|
|
606
|
+
Log.e(TAG, "Getting Null Activity !!");
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
} catch (Exception e) {
|
|
610
|
+
Log.i(TAG, "SHOW NOTIFICATIONS ERROR : " + e);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
}
|
|
614
|
+
|
|
369
615
|
/* 3 - Event Tracking */
|
|
370
616
|
@ReactMethod
|
|
371
617
|
public void event(String eventName, ReadableMap attributes, String ltv, String scope, Callback callback) {
|
|
@@ -441,6 +687,34 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
|
|
|
441
687
|
Log.i(TAG, "USER IDENTIFIER ERROR : " + e);
|
|
442
688
|
}
|
|
443
689
|
}
|
|
690
|
+
|
|
691
|
+
@ReactMethod
|
|
692
|
+
public void setUserIdentifier(ReadableMap attributes, final Callback callback) {
|
|
693
|
+
try {
|
|
694
|
+
Log.i(TAG, "setUserIdentifier !!");
|
|
695
|
+
JSONObject mAttributes = null;
|
|
696
|
+
|
|
697
|
+
if (attributes != null) {
|
|
698
|
+
HashMap<String, Object> temp = attributes.toHashMap();
|
|
699
|
+
mAttributes = new JSONObject(temp);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
if (mAttributes != null) {
|
|
703
|
+
Log.i(TAG, "Attributes : " + mAttributes);
|
|
704
|
+
} else {
|
|
705
|
+
Log.i(TAG, "Attributes : null");
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
NotifyVisitorsApi.getInstance(reactContext).userIdentifier(mAttributes, new OnUserTrackListener() {
|
|
709
|
+
@Override
|
|
710
|
+
public void onResponse(JSONObject data) {
|
|
711
|
+
callback.invoke(data.toString());
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
} catch (Exception e) {
|
|
715
|
+
Log.i(TAG, "SET USER IDENTIFIER ERROR : " + e);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
444
718
|
|
|
445
719
|
/* 5 - chatBot */
|
|
446
720
|
@ReactMethod
|
|
@@ -775,6 +1049,25 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
|
|
|
775
1049
|
}
|
|
776
1050
|
}
|
|
777
1051
|
|
|
1052
|
+
@ReactMethod
|
|
1053
|
+
public void knownUserIdentified(final Callback callback) {
|
|
1054
|
+
onKnownUserIdentifiedCallback = callback;
|
|
1055
|
+
|
|
1056
|
+
try {
|
|
1057
|
+
Log.i(TAG, "KNOWN USER IDENTIFIED !!");
|
|
1058
|
+
NotifyVisitorsApi.getInstance(reactContext).knownUserIdentified(new OnKnownUserFound() {
|
|
1059
|
+
@Override
|
|
1060
|
+
public void getNvUid(JSONObject data) {
|
|
1061
|
+
if (data != null) {
|
|
1062
|
+
sendEvent(KNOWN_USER_IDENTIFIED_CALLBACK, data.toString());
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
} catch (Exception e) {
|
|
1067
|
+
Log.i(TAG, "KNOWN USER IDENTIFIED ERROR : " + e);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
|
|
778
1071
|
/* 15 - Unique NotifyVisitors Identification */
|
|
779
1072
|
@ReactMethod
|
|
780
1073
|
public void getNvUID(final Callback callback) {
|
|
@@ -868,7 +1161,8 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
|
|
|
868
1161
|
public void stopNotifications() {
|
|
869
1162
|
try {
|
|
870
1163
|
Log.i(TAG, "STOP NOTIFICATIONS !!");
|
|
871
|
-
NotifyVisitorsApi.getInstance(reactContext).stopNotification();
|
|
1164
|
+
// NotifyVisitorsApi.getInstance(reactContext).stopNotification();
|
|
1165
|
+
if (reactContext.getCurrentActivity() != null) NotifyVisitorsApi.getInstance(reactContext.getCurrentActivity()).stopNotification();
|
|
872
1166
|
} catch (Exception e) {
|
|
873
1167
|
Log.i(TAG, "STOP NOTIFICATIONS ERROR : " + e);
|
|
874
1168
|
}
|
|
@@ -1074,6 +1368,60 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
|
|
|
1074
1368
|
|
|
1075
1369
|
}
|
|
1076
1370
|
|
|
1371
|
+
@ReactMethod
|
|
1372
|
+
private void isPayloadFromNvPlatform(String pushPayload, Callback callback) {
|
|
1373
|
+
Log.i(TAG, "Is Payload From Nv Platform !!");
|
|
1374
|
+
boolean b = false;
|
|
1375
|
+
|
|
1376
|
+
try {
|
|
1377
|
+
JSONObject jsonObject = new JSONObject(pushPayload);
|
|
1378
|
+
Intent intent = new Intent();
|
|
1379
|
+
Iterator<String> keys = jsonObject.keys();
|
|
1380
|
+
while (keys.hasNext()) {
|
|
1381
|
+
String key = keys.next();
|
|
1382
|
+
// Process key-value pairs
|
|
1383
|
+
Object value = jsonObject.get(key);
|
|
1384
|
+
if (value instanceof Integer) {
|
|
1385
|
+
intent.putExtra(key, (Integer) value);
|
|
1386
|
+
} else if (value instanceof String) {
|
|
1387
|
+
intent.putExtra(key, (String) value);
|
|
1388
|
+
} else if (value instanceof Boolean) {
|
|
1389
|
+
intent.putExtra(key, (Boolean) value);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
b = NotifyVisitorsApi.getInstance(reactContext).isPayloadFromNvPlatform(intent);
|
|
1393
|
+
} catch (Exception e) {
|
|
1394
|
+
Log.e(TAG, "error = " + e);
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
if (b) callback.invoke("true"); else callback.invoke("false");
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
@ReactMethod
|
|
1401
|
+
private void getNV_FCMPayload(String pushPayload) {
|
|
1402
|
+
Log.i(TAG, "Get NV FCM Payload !!");
|
|
1403
|
+
|
|
1404
|
+
try {
|
|
1405
|
+
JSONObject jsonObject = new JSONObject(pushPayload);
|
|
1406
|
+
Intent intent = new Intent();
|
|
1407
|
+
Iterator<String> keys = jsonObject.keys();
|
|
1408
|
+
while (keys.hasNext()) {
|
|
1409
|
+
String key = keys.next();
|
|
1410
|
+
// Process key-value pairs
|
|
1411
|
+
Object value = jsonObject.get(key);
|
|
1412
|
+
if (value instanceof Integer) {
|
|
1413
|
+
intent.putExtra(key, (Integer) value);
|
|
1414
|
+
} else if (value instanceof String) {
|
|
1415
|
+
intent.putExtra(key, (String) value);
|
|
1416
|
+
} else if (value instanceof Boolean) {
|
|
1417
|
+
intent.putExtra(key, (Boolean) value);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
NotifyVisitorsApi.getInstance(reactContext).getNV_FCMPayload(intent);
|
|
1421
|
+
} catch (Exception e) {
|
|
1422
|
+
Log.e(TAG, "error = " + e);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1077
1425
|
|
|
1078
1426
|
/* On Activity Result */
|
|
1079
1427
|
@Override
|
|
@@ -1100,20 +1448,19 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
|
|
|
1100
1448
|
Log.i(TAG, "INSIDE HANDLE INTENT !!!!");
|
|
1101
1449
|
|
|
1102
1450
|
JSONObject dataInfo, finalDataInfo;
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
1451
|
String action = intent.getAction();
|
|
1106
1452
|
Uri url = intent.getData();
|
|
1107
1453
|
finalDataInfo = new JSONObject();
|
|
1108
1454
|
|
|
1109
1455
|
// if app was not launched by the url - ignore
|
|
1110
1456
|
if (!Intent.ACTION_VIEW.equals(action) || url == null) {
|
|
1111
|
-
if (intent.hasExtra("source") && intent.getStringExtra("source").equalsIgnoreCase("nv")) {
|
|
1457
|
+
if ((intent.hasExtra("source") && intent.getStringExtra("source").equalsIgnoreCase("nv")) || (intent.hasExtra("notifyvisitors_cta"))) {
|
|
1112
1458
|
try {
|
|
1113
1459
|
Bundle bundle = intent.getExtras();
|
|
1114
1460
|
if (bundle != null) {
|
|
1115
1461
|
dataInfo = new JSONObject();
|
|
1116
1462
|
String nv_type = "push";
|
|
1463
|
+
String nv_new_payload = (intent.hasExtra("notifyvisitors_cta") ? intent.getStringExtra("notifyvisitors_cta") : "");
|
|
1117
1464
|
for (String key : bundle.keySet()) {
|
|
1118
1465
|
try {
|
|
1119
1466
|
dataInfo.put(key, JSONObject.wrap(bundle.get(key)));
|
|
@@ -1124,30 +1471,42 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
|
|
|
1124
1471
|
//e.printStackTrace();
|
|
1125
1472
|
}
|
|
1126
1473
|
}
|
|
1474
|
+
} catch (Exception e) {
|
|
1475
|
+
//e.printStackTrace();
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1127
1478
|
|
|
1479
|
+
if (dataInfo.has("notifyvisitors_cta")) {
|
|
1480
|
+
try {
|
|
1481
|
+
dataInfo.remove("notifyvisitors_cta");
|
|
1128
1482
|
} catch (Exception e) {
|
|
1129
1483
|
//e.printStackTrace();
|
|
1130
1484
|
}
|
|
1131
1485
|
}
|
|
1486
|
+
|
|
1132
1487
|
dataInfo.put("type", nv_type);
|
|
1133
1488
|
finalDataInfo.put("parameters", dataInfo);
|
|
1489
|
+
if (nv_new_payload != null && !nv_new_payload.isEmpty()) {
|
|
1490
|
+
finalDataInfo.put("notifyvisitors_cta", new JSONObject(nv_new_payload));
|
|
1491
|
+
}
|
|
1134
1492
|
finalData = finalDataInfo.toString();
|
|
1493
|
+
//Log.d(TAG, "finalDataInfo => " + finalDataInfo);
|
|
1135
1494
|
sendEvent(PUSH_BANNER_CLICK_EVENT, finalData);
|
|
1136
1495
|
|
|
1137
1496
|
// try to send callback in show function
|
|
1138
|
-
try {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
} catch (Exception e) {
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1497
|
+
// try {
|
|
1498
|
+
// if (nv_type.equalsIgnoreCase("banner")) {
|
|
1499
|
+
// JSONObject bannerData = new JSONObject();
|
|
1500
|
+
// bannerData.put("status", "success");
|
|
1501
|
+
// bannerData.put("eventName", "Banner Clicked");
|
|
1502
|
+
// bannerData.put("callbackType", "banner");
|
|
1503
|
+
// bannerData.put("parameters", dataInfo);
|
|
1504
|
+
// sendResponse(bannerData);
|
|
1505
|
+
// nvInAppFound = true;
|
|
1506
|
+
// }
|
|
1507
|
+
// } catch (Exception e) {
|
|
1508
|
+
// Log.i(TAG, "SEND DATA IN SHOW METHOD ERROR : " + e);
|
|
1509
|
+
// }
|
|
1151
1510
|
|
|
1152
1511
|
}
|
|
1153
1512
|
} catch (Exception e) {
|
|
@@ -1202,7 +1561,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
|
|
|
1202
1561
|
private void sendResponse(JSONObject response) {
|
|
1203
1562
|
try {
|
|
1204
1563
|
if (response != null) {
|
|
1205
|
-
String eventName = response.getString("eventName");
|
|
1564
|
+
String eventName = (response.has("eventName")) ? response.getString("eventName") : "";
|
|
1206
1565
|
|
|
1207
1566
|
// check clicked is banner or survey
|
|
1208
1567
|
if (eventName.equalsIgnoreCase("Survey Submit") || eventName.equalsIgnoreCase("Survey Attempt") || eventName.equalsIgnoreCase("Banner Impression") || eventName.equalsIgnoreCase("Banner Clicked")) {
|
|
@@ -1224,6 +1583,10 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
|
|
|
1224
1583
|
if (commonCallback != null) {
|
|
1225
1584
|
sendEvent(COMMON_SHOW_EVENT_CALLBACK, response.toString());
|
|
1226
1585
|
}
|
|
1586
|
+
|
|
1587
|
+
if (centerCallback != null) {
|
|
1588
|
+
sendEvent(CENTER_CALLBACK, response.toString());
|
|
1589
|
+
}
|
|
1227
1590
|
} else {
|
|
1228
1591
|
Log.i(TAG, "RESPONSE IS NULL !!");
|
|
1229
1592
|
}
|
package/index.d.ts
CHANGED
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
export default class Notifyvisitors {
|
|
2
|
+
/* 1 - inApp-Banner & inApp-Surveys */
|
|
2
3
|
static show(
|
|
3
4
|
tokens: any,
|
|
4
5
|
customObjects: any,
|
|
5
6
|
fragmentName: any,
|
|
6
7
|
nvCallback: any
|
|
7
8
|
): void;
|
|
9
|
+
|
|
10
|
+
static showInAppMessage(
|
|
11
|
+
tokens: any,
|
|
12
|
+
customObjects: any,
|
|
13
|
+
fragmentName: any,
|
|
14
|
+
nvCallback: any
|
|
15
|
+
): void;
|
|
16
|
+
|
|
17
|
+
static stopNotifications(): void;
|
|
18
|
+
static getEventSurveyInfo(nvCallback: any): void;
|
|
19
|
+
|
|
20
|
+
/* 2 - Notification Center */
|
|
21
|
+
static openNotificationCenter(
|
|
22
|
+
mAppInboxInfo: any,
|
|
23
|
+
dismissValue: any,
|
|
24
|
+
callback: any
|
|
25
|
+
): void;
|
|
8
26
|
static showNotifications(mAppInboxInfo: any, dismissValue: any): void;
|
|
27
|
+
static getNotificationCenterData(callback: any): void;
|
|
28
|
+
static getNotificationCenterCount(tabCountInfo: any, callback: any): void;
|
|
29
|
+
static getNotificationDataListener(callback: any): void;
|
|
30
|
+
static getNotificationCount(callback: any): void;
|
|
31
|
+
|
|
32
|
+
/* 3 - Track Events */
|
|
9
33
|
static event(
|
|
10
34
|
eventName: any,
|
|
11
35
|
attributes: any,
|
|
@@ -13,8 +37,42 @@ export default class Notifyvisitors {
|
|
|
13
37
|
scope: any,
|
|
14
38
|
nvCallback: any
|
|
15
39
|
): void;
|
|
40
|
+
|
|
41
|
+
/* 4 - Push Notifications */
|
|
42
|
+
static scheduleNotification(
|
|
43
|
+
nid: any,
|
|
44
|
+
tag: any,
|
|
45
|
+
time: any,
|
|
46
|
+
title: any,
|
|
47
|
+
message: any,
|
|
48
|
+
url: any,
|
|
49
|
+
icon: any
|
|
50
|
+
): void;
|
|
51
|
+
static subscribePushCategory(categoryInfo: any, unSubscribe2All: any): void;
|
|
52
|
+
static stopGeofencePushforDateTime(dateTime: any, additionalHours: any): void;
|
|
53
|
+
static getRegistrationToken(nvCallback: any): void;
|
|
54
|
+
|
|
55
|
+
/* 5 - Track User */
|
|
16
56
|
static userIdentifier(userID: any, sJsonObject: any): void;
|
|
57
|
+
static setUserIdentifier(sJsonObject: any, callback: any): void;
|
|
58
|
+
static getNvUID(callback: any): void;
|
|
59
|
+
static knownUserIdentified(callback: any): void;
|
|
60
|
+
|
|
61
|
+
/* 6 - Chatbot (Deprecated and temporarly not available in Native SDKs) */
|
|
17
62
|
static startChatBot(screenName: any, nvCallback: any): void;
|
|
63
|
+
|
|
64
|
+
/* 7 - GetLinkInfo() and other callback handlers */
|
|
65
|
+
static getLinkInfo(nvCallback: any): void;
|
|
66
|
+
|
|
67
|
+
/* 8 - Other Methods */
|
|
68
|
+
static requestInAppReview(nvCallback: any): void;
|
|
69
|
+
|
|
70
|
+
/* 9 - Android Specific methods */
|
|
71
|
+
static nativePushPermissionPrompt(callback: any): void;
|
|
72
|
+
static pushPermissionPrompt(
|
|
73
|
+
pushPromptInfo: PushPromptInfo,
|
|
74
|
+
callback: any
|
|
75
|
+
): void;
|
|
18
76
|
static createNotificationChannel(
|
|
19
77
|
chId: any,
|
|
20
78
|
chName: any,
|
|
@@ -25,42 +83,22 @@ export default class Notifyvisitors {
|
|
|
25
83
|
lightColor: any,
|
|
26
84
|
soundFileName: any
|
|
27
85
|
): void;
|
|
86
|
+
|
|
28
87
|
static deleteNotificationChannel(channelId: any): void;
|
|
29
88
|
static createNotificationChannelGroup(groupId: any, groupName: any): void;
|
|
30
89
|
static deleteNotificationChannelGroup(groupId: any): void;
|
|
31
|
-
static getNotificationCenterCount(tabCountInfo: any, callback: any): void;
|
|
32
|
-
static getRegistrationToken(nvCallback: any): void;
|
|
33
|
-
static requestInAppReview(nvCallback: any): void;
|
|
34
|
-
static subscribePushCategory(categoryInfo: any, unSubscribe2All: any): void;
|
|
35
|
-
static getLinkInfo(nvCallback: any): void;
|
|
36
|
-
static getNvUID(callback: any): void;
|
|
37
|
-
static getNotificationDataListener(callback: any): void;
|
|
38
|
-
static getNotificationCenterData(callback: any): void;
|
|
39
90
|
static setAutoStartPermission_android_only(): void;
|
|
40
|
-
static stopNotifications(): void;
|
|
41
91
|
static clearPushData(): void;
|
|
42
92
|
static checkPushActive(nv_signal: any): void;
|
|
43
|
-
static
|
|
44
|
-
static
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
time: any,
|
|
48
|
-
title: any,
|
|
49
|
-
message: any,
|
|
50
|
-
url: any,
|
|
51
|
-
icon: any
|
|
52
|
-
): void;
|
|
53
|
-
static getEventSurveyInfo(nvCallback: any): void;
|
|
54
|
-
static getNotificationCount(callback: any): void;
|
|
93
|
+
static isPayloadFromNvPlatform(pushPayload: any, callback: any): void;
|
|
94
|
+
static getNV_FCMPayload(pushPayload: any): void;
|
|
95
|
+
|
|
96
|
+
/* 10 - iOS Specific methods */
|
|
55
97
|
static scrollViewDidScroll_iOS_only(): void;
|
|
56
|
-
static promptForPushNotificationsWithUserResponse(callback: any): void;
|
|
57
|
-
static pushPermissionPrompt(
|
|
58
|
-
pushPromptInfo: PushPromptInfo,
|
|
59
|
-
callback: any
|
|
60
|
-
): void;
|
|
61
|
-
static nativePushPermissionPrompt(callback: any): void;
|
|
98
|
+
// static promptForPushNotificationsWithUserResponse(callback: any): void;
|
|
62
99
|
}
|
|
63
100
|
|
|
101
|
+
/* 11 - Android Specific Push Prompt Customisation */
|
|
64
102
|
export class PushPromptInfo {
|
|
65
103
|
title: String;
|
|
66
104
|
titleTextColor: String;
|