-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33386 from Expensify/arosiclair-disable-clear-not…
…ifs-android Disable clearReportNotifications on Android
- Loading branch information
Showing
6 changed files
with
50 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/libs/Notification/clearReportNotifications/index.android.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ClearReportNotifications from './types'; | ||
|
||
/** | ||
* This is a temporary fix for issues with our Notification Cache not being cleared in Android. | ||
* More info here: https://github.com/Expensify/App/issues/33367#issuecomment-1865196381 | ||
*/ | ||
const clearReportNotifications: ClearReportNotifications = () => {}; | ||
|
||
export default clearReportNotifications; |
41 changes: 41 additions & 0 deletions
41
src/libs/Notification/clearReportNotifications/index.ios.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import Airship, {PushPayload} from '@ua/react-native-airship'; | ||
import Log from '@libs/Log'; | ||
import {NotificationData} from '@libs/Notification/PushNotification/NotificationType'; | ||
import CONST from '@src/CONST'; | ||
import ClearReportNotifications from './types'; | ||
|
||
const parseNotificationAndReportIDs = (pushPayload: PushPayload) => { | ||
let payload = pushPayload.extras.payload; | ||
if (typeof payload === 'string') { | ||
payload = JSON.parse(payload); | ||
} | ||
const data = payload as NotificationData; | ||
return { | ||
notificationID: pushPayload.notificationId, | ||
reportID: String(data.reportID), | ||
}; | ||
}; | ||
|
||
const clearReportNotifications: ClearReportNotifications = (reportID: string) => { | ||
Log.info('[PushNotification] clearing report notifications', false, {reportID}); | ||
|
||
Airship.push | ||
.getActiveNotifications() | ||
.then((pushPayloads) => { | ||
const reportNotificationIDs = pushPayloads.reduce<string[]>((notificationIDs, pushPayload) => { | ||
const notification = parseNotificationAndReportIDs(pushPayload); | ||
if (notification.notificationID && notification.reportID === reportID) { | ||
notificationIDs.push(notification.notificationID); | ||
} | ||
return notificationIDs; | ||
}, []); | ||
|
||
Log.info(`[PushNotification] found ${reportNotificationIDs.length} notifications to clear`, false, {reportID}); | ||
reportNotificationIDs.forEach((notificationID) => Airship.push.clearNotification(notificationID)); | ||
}) | ||
.catch((error) => { | ||
Log.alert(`${CONST.ERROR.ENSURE_BUGBOT} [PushNotification] BrowserNotifications.clearReportNotifications threw an error. This should never happen.`, {reportID, error}); | ||
}); | ||
}; | ||
|
||
export default clearReportNotifications; |
5 changes: 0 additions & 5 deletions
5
src/libs/Notification/clearReportNotifications/index.native.ts
This file was deleted.
Oops, something went wrong.