react-native-notifyvisitors 4.3.1 → 4.3.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.
@@ -34,8 +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'
38
- implementation 'com.notifyvisitors.notifyvisitors:notifyvisitors:v5.4.7.1
37
+ implementation 'com.notifyvisitors.notifyvisitors:notifyvisitors:v5.4.7.1'
39
38
 
40
39
  implementation platform('com.google.firebase:firebase-bom:30.3.1')
41
40
  implementation ('com.google.firebase:firebase-messaging')
@@ -14,7 +14,7 @@
14
14
  <application>
15
15
  <service
16
16
  android:name="com.notifyvisitors.notifyvisitors.NVFirebaseMessagingService"
17
- android:exported="true">
17
+ android:exported="false">
18
18
  <intent-filter>
19
19
  <action android:name="com.google.firebase.MESSAGING_EVENT" />
20
20
  </intent-filter>
@@ -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.1";
46
+ private static final String PLUGIN_VERSION = "4.3.3";
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) {
@@ -432,13 +456,13 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
432
456
  mActivity.runOnUiThread(new Runnable() {
433
457
  @Override
434
458
  public void run() {
435
- NotifyVisitorsApi.getInstance(mActivity).startChatBot(screenName, new OnNotifyBotClickListener() {
436
- @Override
437
- public void onInAppRedirection(JSONObject data) {
438
- String strI = data.toString();
439
- sendEvent(CHAT_BOT_BUTTON_CLICK, strI);
440
- }
441
- });
459
+ // NotifyVisitorsApi.getInstance(mActivity).startChatBot(screenName, new OnNotifyBotClickListener() {
460
+ // @Override
461
+ // public void onInAppRedirection(JSONObject data) {
462
+ // String strI = data.toString();
463
+ // sendEvent(CHAT_BOT_BUTTON_CLICK, strI);
464
+ // }
465
+ // });
442
466
  }
443
467
  });
444
468
  } else {
@@ -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,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
997
1017
  }
998
1018
  }
999
1019
 
1000
- private void intentDataClear() {
1020
+ private void intentDataClear() {
1001
1021
  try {
1002
1022
  new Timer().schedule(new TimerTask() {
1003
1023
  @Override
@@ -1014,7 +1034,6 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
1014
1034
  }
1015
1035
 
1016
1036
 
1017
-
1018
1037
  /* On Activity Result */
1019
1038
  @Override
1020
1039
  public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
@@ -1073,6 +1092,22 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
1073
1092
  finalDataInfo.put("parameters", dataInfo);
1074
1093
  finalData = finalDataInfo.toString();
1075
1094
  sendEvent(PUSH_BANNER_CLICK_EVENT, finalData);
1095
+
1096
+ // try to send callback in show function
1097
+ try {
1098
+ if (nv_type.equalsIgnoreCase("banner")) {
1099
+ JSONObject bannerData = new JSONObject();
1100
+ bannerData.put("status", "success");
1101
+ bannerData.put("eventName", "Banner Clicked");
1102
+ bannerData.put("callbackType", "banner");
1103
+ bannerData.put("parameters", dataInfo);
1104
+ sendResponse(bannerData);
1105
+ nvInAppFound = true;
1106
+ }
1107
+ } catch (Exception e) {
1108
+ Log.i(TAG, "SEND DATA IN SHOW METHOD ERROR : " + e);
1109
+ }
1110
+
1076
1111
  }
1077
1112
  } catch (Exception e) {
1078
1113
  Log.i(TAG, "HANDLE INTENT PARSE DATA ERROR : " + e);
@@ -1115,9 +1150,7 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
1115
1150
  /* Send Event Callback to React Native Page */
1116
1151
  private void sendEvent(String eventName, String params) {
1117
1152
  try {
1118
- reactContext
1119
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
1120
- .emit(eventName, params);
1153
+ reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params);
1121
1154
  } catch (Exception e) {
1122
1155
  Log.i(TAG, "SEND EVENT ERROR :" + e);
1123
1156
  }
@@ -1131,10 +1164,8 @@ public class RNNotifyvisitorsModule extends ReactContextBaseJavaModule implement
1131
1164
  String eventName = response.getString("eventName");
1132
1165
 
1133
1166
  // 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")) {
1167
+ if (eventName.equalsIgnoreCase("Survey Submit") || eventName.equalsIgnoreCase("Survey Attempt") || eventName.equalsIgnoreCase("Banner Impression") || eventName.equalsIgnoreCase("Banner Clicked")) {
1168
+ nvInAppFound = true;
1138
1169
  if (showCallback != null) {
1139
1170
  sendEvent(SHOW_CALLBACK, response.toString());
1140
1171
  } else {
@@ -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.1 !!");
35
+ NSLog(@"RN-NotifyVisitors PLUGIN VERSION : 4.3.3 !!");
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.1",
3
+ "version": "4.3.3",
4
4
  "description": "React Native Notifyvisitors SDK for push notifications and surveys",
5
5
  "main": "index",
6
6
  "scripts": {