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 @@ -5,7 +5,6 @@ import { AppRegistry, Platform, Alert, LogBox } from 'react-native'; import type { RemoteMessage, NotificationOpen } from 'react-native-firebase'; import { Notification as InAppNotification } from 'react-native-in-app-message'; -import NotificationsIOS from 'react-native-notifications'; import { useDispatch } from 'react-redux'; import { @@ -64,6 +63,7 @@ import { requestIOSPushPermissions, iosPushPermissionResponseReceived, + CommIOSNotifications, getCommIOSNotificationsEventEmitter, } from './ios'; @@ -266,7 +266,7 @@ updateBadgeCount() { const curUnreadCount = this.props.unreadCount; if (Platform.OS === 'ios') { - NotificationsIOS.setBadgesCount(curUnreadCount); + CommIOSNotifications.setBadgesCount(curUnreadCount); } else if (Platform.OS === 'android') { getFirebase().notifications().setBadge(curUnreadCount); } @@ -274,7 +274,7 @@ clearAllNotifs() { if (Platform.OS === 'ios') { - NotificationsIOS.removeAllDeliveredNotifications(); + CommIOSNotifications.removeAllDeliveredNotifications(); } else if (Platform.OS === 'android') { getFirebase().notifications().removeAllDeliveredNotifications(); } @@ -286,7 +286,7 @@ return; } if (Platform.OS === 'ios') { - NotificationsIOS.getDeliveredNotifications(notifications => + CommIOSNotifications.getDeliveredNotifications(notifications => PushHandler.clearDeliveredIOSNotificationsForThread( activeThread, notifications, @@ -306,12 +306,12 @@ ) { const identifiersToClear = []; for (const notification of notifications) { - if (notification['thread-id'] === threadID) { + if (notification.threadID === threadID) { identifiersToClear.push(notification.identifier); } } if (identifiersToClear) { - NotificationsIOS.removeDeliveredNotifications(identifiersToClear); + CommIOSNotifications.removeDeliveredNotifications(identifiersToClear); } } @@ -461,7 +461,9 @@ ) => { const notification = new CommIOSNotification(rawNotification); if (notification.getData() && notification.getData().action === 'CLEAR') { - notification.finish(NotificationsIOS.FetchResult.NoData); + notification.finish( + CommIOSNotifications.getConstants().FETCH_RESULT_NO_DATA, + ); return; } if (Date.now() < this.appStarted + 1500) { @@ -470,13 +472,17 @@ // callback shouldn't be triggered at all. To avoid weirdness we are // ignoring any foreground notification received within the first second // of the app being started, since they are most likely to be erroneous. - notification.finish(NotificationsIOS.FetchResult.NoData); + notification.finish( + CommIOSNotifications.getConstants().FETCH_RESULT_NO_DATA, + ); return; } const threadID = notification.getData().threadID; if (!threadID) { console.log('Notification with missing threadID received!'); - notification.finish(NotificationsIOS.FetchResult.NoData); + notification.finish( + CommIOSNotifications.getConstants().FETCH_RESULT_NO_DATA, + ); return; } const messageInfos = notification.getData().messageInfos; @@ -498,7 +504,9 @@ 'Non-rescind foreground notification without alert received!', ); } - notification.finish(NotificationsIOS.FetchResult.NewData); + notification.finish( + CommIOSNotifications.getConstants().FETCH_RESULT_NEW_DATA, + ); }; onPushNotifBootsApp() { @@ -516,13 +524,17 @@ const threadID = notification.getData().threadID; if (!threadID) { console.log('Notification with missing threadID received!'); - notification.finish(NotificationsIOS.FetchResult.NoData); + notification.finish( + CommIOSNotifications.getConstants().FETCH_RESULT_NO_DATA, + ); return; } const messageInfos = notification.getData().messageInfos; this.saveMessageInfos(messageInfos); this.onPressNotificationForThread(threadID, true); - notification.finish(NotificationsIOS.FetchResult.NewData); + notification.finish( + CommIOSNotifications.getConstants().FETCH_RESULT_NEW_DATA, + ); }; showInAppNotification(threadID: string, message: string, title?: ?string) {