Skip to content

Commit 31902b9

Browse files
committed
fix: do not clear other notifications on open a notification
1 parent 2fa5ae3 commit 31902b9

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java

-6
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public void onReceived() throws InvalidNotificationException {
6666
@Override
6767
public void onOpened() {
6868
digestNotification();
69-
clearAllNotifications();
7069
}
7170

7271
@Override
@@ -193,11 +192,6 @@ protected void postNotification(int id, Notification notification) {
193192
notificationManager.notify(id, notification);
194193
}
195194

196-
protected void clearAllNotifications() {
197-
final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
198-
notificationManager.cancelAll();
199-
}
200-
201195
protected int createNotificationId(Notification notification) {
202196
return (int) System.nanoTime();
203197
}

lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawer.java

-8
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ protected PushNotificationsDrawer(Context context, AppLaunchHelper appLaunchHelp
3131

3232
@Override
3333
public void onAppInit() {
34-
clearAll();
3534
}
3635

3736
@Override
3837
public void onAppVisible() {
39-
clearAll();
4038
}
4139

4240
@Override
@@ -45,7 +43,6 @@ public void onNewActivity(Activity activity) {
4543

4644
@Override
4745
public void onNotificationOpened() {
48-
clearAll();
4946
}
5047

5148
@Override
@@ -65,9 +62,4 @@ public void onAllNotificationsClearRequest() {
6562
final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
6663
notificationManager.cancelAll();
6764
}
68-
69-
protected void clearAll() {
70-
final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
71-
notificationManager.cancelAll();
72-
}
7365
}

lib/android/app/src/test/java/com/wix/reactnativenotifications/core/notification/PushNotificationTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public void onOpened_appVisible_clearNotificationsDrawer() throws Exception {
179179
final PushNotification uut = createUUT();
180180
uut.onOpened();
181181

182-
verify(mNotificationManager).cancelAll();
182+
verify(mNotificationManager, never()).cancelAll();
183183
}
184184

185185
@Test

lib/android/app/src/test/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawerTest.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,21 @@ public void setup() throws Exception {
4040
}
4141

4242
@Test
43-
public void onAppInit_clearAllNotifications() throws Exception {
43+
public void onAppInit_neverClearAllNotifications() throws Exception {
4444
createUUT().onAppInit();
45-
verify(mNotificationManager).cancelAll();
45+
verify(mNotificationManager, never()).cancelAll();
4646
}
4747

4848
@Test
49-
public void onAppVisible_clearAllNotifications() throws Exception {
49+
public void onAppVisible_neverClearAllNotifications() throws Exception {
5050
createUUT().onAppVisible();
51-
verify(mNotificationManager).cancelAll();
51+
verify(mNotificationManager, never()).cancelAll();
52+
}
53+
54+
@Test
55+
public void onNotificationOpened_neverClearAllNotifications() throws Exception {
56+
createUUT().onNotificationOpened()
57+
verify(mNotificationManager, never()).cancelAll();
5258
}
5359

5460
@Test

0 commit comments

Comments
 (0)