diff --git a/native/push/android.js b/native/push/android.js --- a/native/push/android.js +++ b/native/push/android.js @@ -1,6 +1,7 @@ // @flow import invariant from 'invariant'; +import { NativeModules } from 'react-native'; import type { RemoteMessage } from 'react-native-firebase'; import { mergePrefixIntoBody } from 'lib/shared/notif-utils'; @@ -12,6 +13,13 @@ import { store, dispatch } from '../redux/redux-setup'; import { getFirebase } from './firebase'; +type CommAndroidNotificationsModuleType = { + +removeAllActiveNotificationsForThread: (threadID: string) => void, + ... +}; + +const CommAndroidNotifications: CommAndroidNotificationsModuleType = + NativeModules.CommAndroidNotifications; const androidNotificationChannelID = 'default'; const vibrationSpec = [500, 500]; @@ -83,4 +91,5 @@ androidNotificationChannelID, handleAndroidMessage, androidBackgroundMessageTask, + CommAndroidNotifications, }; diff --git a/native/push/push-handler.react.js b/native/push/push-handler.react.js --- a/native/push/push-handler.react.js +++ b/native/push/push-handler.react.js @@ -40,10 +40,7 @@ import { activeMessageListSelector } from '../navigation/nav-selectors'; import { NavContext } from '../navigation/navigation-context'; import type { RootNavigationProp } from '../navigation/root-navigator.react'; -import { - recordNotifPermissionAlertActionType, - clearAndroidNotificationsActionType, -} from '../redux/action-types'; +import { recordNotifPermissionAlertActionType } from '../redux/action-types'; import { useSelector } from '../redux/redux-utils'; import { RootContext, type RootContextType } from '../root-context'; import type { EventSubscription } from '../types/react-native'; @@ -53,6 +50,7 @@ androidNotificationChannelID, handleAndroidMessage, androidBackgroundMessageTask, + CommAndroidNotifications, } from './android'; import { CommIOSNotification, @@ -294,10 +292,9 @@ ), ); } else if (Platform.OS === 'android') { - this.props.dispatch({ - type: clearAndroidNotificationsActionType, - payload: { threadID: activeThread }, - }); + CommAndroidNotifications.removeAllActiveNotificationsForThread( + activeThread, + ); } } diff --git a/native/push/reducer.js b/native/push/reducer.js --- a/native/push/reducer.js +++ b/native/push/reducer.js @@ -12,7 +12,6 @@ rescindAndroidNotificationActionType, type Action, } from '../redux/action-types'; -import { getFirebase } from './firebase'; type RecordAndroidNotificationPayload = { +threadID: string, @@ -62,11 +61,6 @@ if (!state[action.payload.threadID]) { return state; } - for (const notifID of state[action.payload.threadID]) { - getFirebase() - .notifications() - .android.removeDeliveredNotificationsByTag(notifID); - } return { ...state, [action.payload.threadID]: [],