forked from Ivasoft/mattermost-mobile
Do not track foreground notifications when notification is opened (#3111)
This commit is contained in:
committed by
Elias Nahum
parent
e3fd88b7fb
commit
390c30af00
@@ -54,7 +54,9 @@ class PushNotification {
|
||||
this.onNotification(this.deviceNotification);
|
||||
}
|
||||
|
||||
this.trackForegroundNotification(data.channel_id);
|
||||
if (foreground) {
|
||||
this.trackForegroundNotification(data.channel_id);
|
||||
}
|
||||
};
|
||||
|
||||
handleReply = (action, completed) => {
|
||||
|
||||
@@ -59,6 +59,17 @@ describe('PushNotification', () => {
|
||||
expect(foregroundNotifications[channel2ID]).toBe(undefined);
|
||||
});
|
||||
|
||||
it('should NOT track foreground notifications for channel when opened', async () => {
|
||||
let item = await AsyncStorage.getItem(FOREGROUND_NOTIFICATIONS_KEY);
|
||||
expect(item).toBe(null);
|
||||
|
||||
PushNotification.trackForegroundNotification = jest.fn();
|
||||
PushNotification.onNotificationOpened(notification);
|
||||
expect(PushNotification.trackForegroundNotification).not.toBeCalled();
|
||||
item = await AsyncStorage.getItem(FOREGROUND_NOTIFICATIONS_KEY);
|
||||
expect(item).toBe(null);
|
||||
});
|
||||
|
||||
it('should increment badge number when foreground notification is received', () => {
|
||||
const setApplicationIconBadgeNumber = jest.spyOn(PushNotification, 'setApplicationIconBadgeNumber');
|
||||
|
||||
@@ -150,4 +161,4 @@ describe('PushNotification', () => {
|
||||
expect(NotificationsIOS.cancelAllLocalNotifications).toHaveBeenCalled();
|
||||
expect(clearForegroundNotifications).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user