react-native-notifyvisitors 4.3.2 → 4.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,7 +34,7 @@ android {
34
34
  dependencies {
35
35
  implementation fileTree(dir: 'libs', include: ['*.jar'])
36
36
  implementation 'com.facebook.react:react-native:+'
37
- implementation 'com.notifyvisitors.notifyvisitors:notifyvisitors:v5.4.7.1'
37
+ implementation 'com.notifyvisitors.notifyvisitors:notifyvisitors:v5.4.8'
38
38
 
39
39
  implementation platform('com.google.firebase:firebase-bom:30.3.1')
40
40
  implementation ('com.google.firebase:firebase-messaging')
@@ -25,7 +25,6 @@ import com.notifyvisitors.notifyvisitors.interfaces.NotificationListDetailsCallb
25
25
  import com.notifyvisitors.notifyvisitors.interfaces.OnCenterCountListener;
26
26
  import com.notifyvisitors.notifyvisitors.interfaces.OnCenterDataListener;
27
27
  import com.notifyvisitors.notifyvisitors.interfaces.OnEventTrackListener;
28
- import com.notifyvisitors.notifyvisitors.interfaces.OnNotifyBotClickListener;
29
28
  import com.notifyvisitors.notifyvisitors.interfaces.OnPushRuntimePermission;
30
29
  import com.notifyvisitors.notifyvisitors.permission.NVPopupDesign;
31
30
  import com.notifyvisitors.notifyvisitors.push.NVNotificationChannels;
@@ -44,7 +43,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
44
43
 
45
44
  private final ReactApplicationContext reactContext;
46
45
  private static final String TAG = "RN-NotifyVisitors";
47
- private static final String PLUGIN_VERSION = "4.3.2";
46
+ private static final String PLUGIN_VERSION = "4.3.4";
48
47
 
49
48
  private String PUSH_BANNER_CLICK_EVENT = "nv_push_banner_click";
50
49
  private String CHAT_BOT_BUTTON_CLICK = "nv_chat_bot_button_click";
@@ -69,8 +68,10 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
69
68
  JSONObject mTokens;
70
69
  JSONObject mCustomObjects;
71
70
  NVCenterStyleConfig config;
72
-
73
71
  private final int NV_TIME_OUT = 5000;
72
+ private final int NV_BANNER_TIME_OUT = 1200;
73
+
74
+ boolean nvInAppFound = false;
74
75
 
75
76
 
76
77
  /* constructor */
@@ -177,18 +178,41 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
177
178
  @Override
178
179
  public void run() {
179
180
  NotifyVisitorsApi.getInstance(mActivity).show(mTokens, mCustomObjects, fragmentName);
181
+ checkForBannerNotFound();
180
182
  }
181
183
  });
182
184
  } else {
183
185
  Log.e(TAG, "Getting Null Activity !!");
184
186
  }
185
-
186
-
187
187
  } catch (Exception e) {
188
188
  Log.i(TAG, "SHOW ERROR : " + e);
189
189
  }
190
190
  }
191
191
 
192
+ private void checkForBannerNotFound() {
193
+ try {
194
+ new Timer().schedule(new TimerTask() {
195
+ @Override
196
+ public void run() {
197
+ if (!nvInAppFound && showCallback != null) {
198
+ Log.i(TAG, "Banner Not Found to be true !!!!");
199
+ try {
200
+ JSONObject nv_response = new JSONObject();
201
+ nv_response.put("status", "fail");
202
+ nv_response.put("eventName", "Banner InActive");
203
+ nv_response.put("callbackType", "banner");
204
+ sendEvent(SHOW_CALLBACK, nv_response.toString());
205
+ } catch (Exception e) {
206
+ Log.i(TAG, "Banner Not Found Checker ERROR 1: " + e);
207
+ }
208
+ }
209
+ }
210
+ }, NV_BANNER_TIME_OUT);
211
+ } catch (Exception e) {
212
+ Log.i(TAG, "Banner Not Found Checker ERROR 2: " + e);
213
+ }
214
+ }
215
+
192
216
  /* 2 - Notification Center */
193
217
  @ReactMethod
194
218
  public void showNotifications(ReadableMap mAppInboxInfo, final int dismissValue) {
@@ -453,9 +477,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
453
477
 
454
478
  /* 6 - Push Notification Channel */
455
479
  @ReactMethod
456
- public void createNotificationChannel(String chId, String chName, String chDescription,
457
- String chImportance, String enableLights, String shouldVibrate,
458
- String lightColor, String soundFileName) {
480
+ public void createNotificationChannel(String chId, String chName, String chDescription, String chImportance, String enableLights, String shouldVibrate, String lightColor, String soundFileName) {
459
481
  try {
460
482
  Log.i(TAG, "CREATE NOTIFICATION CHANNEL !!");
461
483
 
@@ -784,7 +806,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
784
806
  }, 0);
785
807
  }
786
808
  });
787
- } else {
809
+ } else {
788
810
  Log.e(TAG, "Getting Null Activity !!");
789
811
  }
790
812
  } catch (Exception e) {
@@ -818,7 +840,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
818
840
  Log.i(TAG, "GET NOTIFICATION DATA LISTENER ERROR : " + e);
819
841
  }
820
842
  }
821
-
843
+
822
844
 
823
845
  /* 17 - Auto Start Library Android */
824
846
  @ReactMethod
@@ -883,9 +905,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
883
905
 
884
906
  /* 20 - Trigger Push Notification on Panel */
885
907
  @ReactMethod
886
- public void scheduleNotification(String nid, String tag, String time,
887
- String title, String message, String url,
888
- String icon) {
908
+ public void scheduleNotification(String nid, String tag, String time, String title, String message, String url, String icon) {
889
909
  try {
890
910
  Log.i(TAG, "SCHEDULE NOTIFICATION !!");
891
911
  NotifyVisitorsApi.getInstance(reactContext).scheduleNotification(nid, tag, time, title, message, url, icon);
@@ -987,7 +1007,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
987
1007
  }
988
1008
  }
989
1009
 
990
- @ReactMethod
1010
+ @ReactMethod
991
1011
  public void clearPushData() {
992
1012
  try {
993
1013
  Log.i(TAG, "CLEAR PUSH DATA !!");
@@ -997,7 +1017,21 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
997
1017
  }
998
1018
  }
999
1019
 
1000
- private void intentDataClear() {
1020
+ @ReactMethod
1021
+ public void checkPushActive(String nv_choice) {
1022
+ try {
1023
+ Log.i(TAG, "Check Push Active !!");
1024
+ boolean signal = true;
1025
+ if (nv_choice.equalsIgnoreCase("false")) {
1026
+ signal = false;
1027
+ }
1028
+ NotifyVisitorsApi.getInstance(reactContext).enablePushPermission(signal);
1029
+ } catch (Exception e) {
1030
+ Log.i(TAG, "Check Push Active !! " + e);
1031
+ }
1032
+ }
1033
+
1034
+ private void intentDataClear() {
1001
1035
  try {
1002
1036
  new Timer().schedule(new TimerTask() {
1003
1037
  @Override
@@ -1014,7 +1048,6 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
1014
1048
  }
1015
1049
 
1016
1050
 
1017
-
1018
1051
  /* On Activity Result */
1019
1052
  @Override
1020
1053
  public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
@@ -1073,6 +1106,22 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
1073
1106
  finalDataInfo.put("parameters", dataInfo);
1074
1107
  finalData = finalDataInfo.toString();
1075
1108
  sendEvent(PUSH_BANNER_CLICK_EVENT, finalData);
1109
+
1110
+ // try to send callback in show function
1111
+ try {
1112
+ if (nv_type.equalsIgnoreCase("banner")) {
1113
+ JSONObject bannerData = new JSONObject();
1114
+ bannerData.put("status", "success");
1115
+ bannerData.put("eventName", "Banner Clicked");
1116
+ bannerData.put("callbackType", "banner");
1117
+ bannerData.put("parameters", dataInfo);
1118
+ sendResponse(bannerData);
1119
+ nvInAppFound = true;
1120
+ }
1121
+ } catch (Exception e) {
1122
+ Log.i(TAG, "SEND DATA IN SHOW METHOD ERROR : " + e);
1123
+ }
1124
+
1076
1125
  }
1077
1126
  } catch (Exception e) {
1078
1127
  Log.i(TAG, "HANDLE INTENT PARSE DATA ERROR : " + e);
@@ -1115,9 +1164,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
1115
1164
  /* Send Event Callback to React Native Page */
1116
1165
  private void sendEvent(String eventName, String params) {
1117
1166
  try {
1118
- reactContext
1119
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
1120
- .emit(eventName, params);
1167
+ reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params);
1121
1168
  } catch (Exception e) {
1122
1169
  Log.i(TAG, "SEND EVENT ERROR :" + e);
1123
1170
  }
@@ -1131,10 +1178,8 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
1131
1178
  String eventName = response.getString("eventName");
1132
1179
 
1133
1180
  // check clicked is banner or survey
1134
- if (eventName.equalsIgnoreCase("Survey Submit") ||
1135
- eventName.equalsIgnoreCase("Survey Attempt") ||
1136
- eventName.equalsIgnoreCase("Banner Impression") ||
1137
- eventName.equalsIgnoreCase("Banner Clicked")) {
1181
+ if (eventName.equalsIgnoreCase("Survey Submit") || eventName.equalsIgnoreCase("Survey Attempt") || eventName.equalsIgnoreCase("Banner Impression") || eventName.equalsIgnoreCase("Banner Clicked")) {
1182
+ nvInAppFound = true;
1138
1183
  if (showCallback != null) {
1139
1184
  sendEvent(SHOW_CALLBACK, response.toString());
1140
1185
  } else {
package/index.d.ts CHANGED
@@ -39,6 +39,7 @@ export default class Notifyvisitors {
39
39
  static setAutoStartPermission_android_only(): void;
40
40
  static stopNotifications(): void;
41
41
  static clearPushData(): void;
42
+ static checkPushActive(nv_signal: any): void;
42
43
  static stopGeofencePushforDateTime(dateTime: any, additionalHours: any): void;
43
44
  static scheduleNotification(
44
45
  nid: any,
package/index.js CHANGED
@@ -382,6 +382,18 @@ export default class Notifyvisitors {
382
382
  console.log(e);
383
383
  }
384
384
  }
385
+
386
+ static checkPushActive(nv_signal) {
387
+ console.log("NV- Check Push Active !!");
388
+ try {
389
+ if (Platform.OS === 'android') {
390
+ RNNotifyvisitors.checkPushActive(nv_signal);
391
+ }
392
+ } catch (e) {
393
+ console.log(e);
394
+ }
395
+ }
396
+
385
397
  }
386
398
 
387
399
  export class PushPromptInfo {
@@ -9,6 +9,8 @@ RCTResponseSenderBlock showCallback;
9
9
  RCTResponseSenderBlock eventCallback;
10
10
  RCTResponseSenderBlock commonCallback;
11
11
 
12
+ BOOL nvInAppFound = false;
13
+
12
14
  @implementation RCTEventEmitterDemo{
13
15
  BOOL hasListeners;
14
16
  }
@@ -106,6 +108,7 @@ RCT_EXPORT_METHOD(show:(NSDictionary*_Nullable)nvUserToken customRules:(NSDicti
106
108
  //NSLog(@"Dictionary token 2: %@", [mCustomRule description]);
107
109
  dispatch_async(dispatch_get_main_queue(), ^{
108
110
  [notifyvisitors Show:mUserToken CustomRule:mCustomRule];
111
+ [self checkForBannerNotFound];
109
112
  });
110
113
  }
111
114
  @catch(NSException *exception){
@@ -113,44 +116,27 @@ RCT_EXPORT_METHOD(show:(NSDictionary*_Nullable)nvUserToken customRules:(NSDicti
113
116
  }
114
117
  }
115
118
 
116
-
117
- /* 2 - Open Notification Center */
118
- //RCT_EXPORT_METHOD(showNotifications:(NSMutableDictionary *)appInboxInfo dismiss:(NSString*_Nullable)dismissValue) {
119
- // @try{
120
- // NSLog(@"RN-NotifyVisitors : SHOW NOTIFICATIONS !!");
121
- // [notifyvisitors NotifyVisitorsNotificationCentre];
122
- //
123
- // NSString *nvResourcePlistPath = [[NSBundle mainBundle] pathForResource: @"nvResourceValues" ofType: @"plist"];
124
- // if ([[NSFileManager defaultManager] fileExistsAtPath: nvResourcePlistPath]) {
125
- // NSDictionary *nvResourceData = [NSDictionary dictionaryWithContentsOfFile: nvResourcePlistPath];
126
- // if ([nvResourceData count] > 0) {
127
- // NSDictionary *nvResourceBooleans = [nvResourceData objectForKey: @"nvBooleans"];
128
- //
129
- // if ([nvResourceBooleans count] > 0) {
130
- // if (nvResourceBooleans [@"DismissNotificationCenterOnAction"]) {
131
- // nvDismissNCenterOnAction = [nvResourceBooleans [@"DismissNotificationCenterOnAction"] boolValue];
132
- // } else {
133
- // nvDismissNCenterOnAction = YES;
134
- // }
135
- // NSLog(@"NV DISMISS NOTIFICATION CENTER ON ACTION = %@", nvDismissNCenterOnAction ? @"YES" : @"NO");
136
- //
137
- // } else {
138
- // NSLog(@"NV RESOURCE BOOLEANS NOT FOUND !!");
139
- // }
140
- //
141
- // } else {
142
- // NSLog(@"NV RESOURCE DATA NOT FOUND !!");
143
- // }
144
- //
145
- // } else {
146
- // NSLog(@"NV RESOURCE VALUES PLIST NOT FOUND !!");
147
- // }
148
- //
149
- // }
150
- // @catch(NSException *exception){
151
- // NSLog(@"RN-NotifyVisitors ERROR : %@", exception.reason);
152
- // }
153
- //}
119
+ - (void)checkForBannerNotFound{
120
+ @try{
121
+ NSLog(@"RN-NotifyVisitors : checkForBannerNotFound !!");
122
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
123
+ if (!nvInAppFound && showCallback != nil) {
124
+ NSDictionary * bannerData = @{
125
+ @"status":@"fail",
126
+ @"eventName":@"Banner InActive",
127
+ @"callbackType":@"banner"
128
+ };
129
+ NSError *nvError = nil;
130
+ NSData *nvJsonData = [NSJSONSerialization dataWithJSONObject: bannerData options: NSJSONWritingPrettyPrinted error: &nvError];
131
+ NSString *nvJsonString = [[NSString alloc] initWithData: nvJsonData encoding: NSUTF8StringEncoding];
132
+ [self sendEventWithName:@"nv_show_callback" body:@{@"data":nvJsonString}];
133
+ }
134
+ });
135
+ }
136
+ @catch(NSException *exception){
137
+ NSLog(@"RN-NotifyVisitors Banner Not Found : %@", exception.reason);
138
+ }
139
+ }
154
140
 
155
141
 
156
142
  RCT_EXPORT_METHOD(showNotifications:(NSDictionary*_Nullable)temp dismiss:(NSString*_Nullable)dismissValue) {
@@ -626,8 +612,8 @@ RCT_EXPORT_METHOD(getNotificationCenterData:(RCTResponseSenderBlock)callback) {
626
612
  NSLog(@"RN-NotifyVisitors ERROR : %@", exception.reason);
627
613
  NSError *nvExcError = nil;
628
614
  NSDictionary *nvExcErrorDataResponse = @{@"message" : @"no notification(s)", @"notifications": @[], @"errorDescription" : exception.description};
629
- NSData *nvExcJsonData = [NSJSONSerialization dataWithJSONObject: nvExcErrorDataResponse options:NSJSONWritingPrettyPrinted error: &nvExcError];
630
- NSString *nvExcJsonString = [[NSString alloc] initWithData: nvExcJsonData encoding: NSUTF8StringEncoding];
615
+ NSData *nvExcJsonData = [NSJSONSerialization dataWithJSONObject: nvExcErrorDataResponse options:NSJSONWritingPrettyPrinted error: &nvExcError];
616
+ NSString *nvExcJsonString = [[NSString alloc] initWithData: nvExcJsonData encoding: NSUTF8StringEncoding];
631
617
  callback(@[nvExcJsonString, [NSNull null]]);
632
618
  }
633
619
  }
@@ -741,6 +727,7 @@ RCT_EXPORT_METHOD(scrollViewDidScroll_iOS_only) {
741
727
  NSString * eventName = callback[@"eventName"];
742
728
  // clicked is event or survey
743
729
  if([eventName isEqualToString:@"Survey Submit"] || [eventName isEqualToString:@"Survey Attempt"] || [eventName isEqualToString:@"Banner Impression"] || [eventName isEqualToString:@"Banner Clicked"] ){
730
+ nvInAppFound = true;
744
731
  if(showCallback != NULL){
745
732
  [self sendEventWithName:@"nv_show_callback" body:@{@"data":nvJsonString}];
746
733
  }
@@ -861,3 +848,41 @@ RCT_EXPORT_METHOD(scrollViewDidScroll_iOS_only) {
861
848
  //}
862
849
 
863
850
  //callback(@[exception.reason, [NSNull null]]);
851
+
852
+ /* 2 - Open Notification Center */
853
+ //RCT_EXPORT_METHOD(showNotifications:(NSMutableDictionary *)appInboxInfo dismiss:(NSString*_Nullable)dismissValue) {
854
+ // @try{
855
+ // NSLog(@"RN-NotifyVisitors : SHOW NOTIFICATIONS !!");
856
+ // [notifyvisitors NotifyVisitorsNotificationCentre];
857
+ //
858
+ // NSString *nvResourcePlistPath = [[NSBundle mainBundle] pathForResource: @"nvResourceValues" ofType: @"plist"];
859
+ // if ([[NSFileManager defaultManager] fileExistsAtPath: nvResourcePlistPath]) {
860
+ // NSDictionary *nvResourceData = [NSDictionary dictionaryWithContentsOfFile: nvResourcePlistPath];
861
+ // if ([nvResourceData count] > 0) {
862
+ // NSDictionary *nvResourceBooleans = [nvResourceData objectForKey: @"nvBooleans"];
863
+ //
864
+ // if ([nvResourceBooleans count] > 0) {
865
+ // if (nvResourceBooleans [@"DismissNotificationCenterOnAction"]) {
866
+ // nvDismissNCenterOnAction = [nvResourceBooleans [@"DismissNotificationCenterOnAction"] boolValue];
867
+ // } else {
868
+ // nvDismissNCenterOnAction = YES;
869
+ // }
870
+ // NSLog(@"NV DISMISS NOTIFICATION CENTER ON ACTION = %@", nvDismissNCenterOnAction ? @"YES" : @"NO");
871
+ //
872
+ // } else {
873
+ // NSLog(@"NV RESOURCE BOOLEANS NOT FOUND !!");
874
+ // }
875
+ //
876
+ // } else {
877
+ // NSLog(@"NV RESOURCE DATA NOT FOUND !!");
878
+ // }
879
+ //
880
+ // } else {
881
+ // NSLog(@"NV RESOURCE VALUES PLIST NOT FOUND !!");
882
+ // }
883
+ //
884
+ // }
885
+ // @catch(NSException *exception){
886
+ // NSLog(@"RN-NotifyVisitors ERROR : %@", exception.reason);
887
+ // }
888
+ //}
@@ -32,7 +32,7 @@ int nvCheckPushClickTimeCounter = 0;
32
32
 
33
33
  +(void)Initialize{
34
34
  NSLog(@"RN-NotifyVisitors : INITIALIZE !!");
35
- NSLog(@"RN-NotifyVisitors PLUGIN VERSION : 4.3.2 !!");
35
+ NSLog(@"RN-NotifyVisitors PLUGIN VERSION : 4.3.4 !!");
36
36
  NSString *nvMode = nil;
37
37
  #if DEBUG
38
38
  nvMode = @"debug";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-notifyvisitors",
3
- "version": "4.3.2",
3
+ "version": "4.3.4",
4
4
  "description": "React Native Notifyvisitors SDK for push notifications and surveys",
5
5
  "main": "index",
6
6
  "scripts": {