diff --git a/src/libs/Notification/PushNotification/backgroundRefresh/index.android.ts b/src/libs/Notification/PushNotification/backgroundRefresh/index.android.ts deleted file mode 100644 index 15c26b8648fe..000000000000 --- a/src/libs/Notification/PushNotification/backgroundRefresh/index.android.ts +++ /dev/null @@ -1,50 +0,0 @@ -import Onyx from 'react-native-onyx'; -import Log from '@libs/Log'; -import Visibility from '@libs/Visibility'; -import * as App from '@userActions/App'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type BackgroundRefresh from './types'; - -function getLastOnyxUpdateID(): Promise { - return new Promise((resolve) => { - const connectionID = Onyx.connect({ - key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT, - callback: (lastUpdateIDAppliedToClient) => { - Onyx.disconnect(connectionID); - resolve(lastUpdateIDAppliedToClient); - }, - }); - }); -} - -/** - * Runs our reconnectApp action if the app is in the background. - * - * We use this to refresh the app in the background after receiving a push notification (native only). Since the full app - * wakes on iOS and by extension runs reconnectApp already, this is a no-op on everything but Android. - */ -const backgroundRefresh: BackgroundRefresh = () => { - if (Visibility.isVisible()) { - return; - } - - getLastOnyxUpdateID() - .then((lastUpdateIDAppliedToClient) => { - /** - * ReconnectApp waits on the isReadyToOpenApp promise to resolve and this normally only resolves when the LHN is rendered. - * However on Android, this callback is run in the background using a Headless JS task which does not render the React UI, - * so we must manually run confirmReadyToOpenApp here instead. - * - * See more here: https://reactnative.dev/docs/headless-js-android - */ - App.confirmReadyToOpenApp(); - Log.info('[PushNotification] Sending ReconnectApp'); - App.reconnectApp(lastUpdateIDAppliedToClient ?? undefined); - }) - .catch((error) => { - Log.alert(`${CONST.ERROR.ENSURE_BUGBOT} [PushNotification] backgroundRefresh failed. This should never happen.`, {error}); - }); -}; - -export default backgroundRefresh; diff --git a/src/libs/Notification/PushNotification/backgroundRefresh/index.ts b/src/libs/Notification/PushNotification/backgroundRefresh/index.ts deleted file mode 100644 index 54fd14e219a9..000000000000 --- a/src/libs/Notification/PushNotification/backgroundRefresh/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type BackgroundRefresh from './types'; - -/** - * Runs our reconnectApp action if the app is in the background. - * - * We use this to refresh the app in the background after receiving a push notification (native only). Since the full app - * wakes on iOS and by extension runs reconnectApp already, this is a no-op on everything but Android. - */ -const backgroundRefresh: BackgroundRefresh = () => {}; - -export default backgroundRefresh; diff --git a/src/libs/Notification/PushNotification/backgroundRefresh/types.ts b/src/libs/Notification/PushNotification/backgroundRefresh/types.ts deleted file mode 100644 index d3d1ee44a1fd..000000000000 --- a/src/libs/Notification/PushNotification/backgroundRefresh/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -type BackgroundRefresh = () => void; - -export default BackgroundRefresh; diff --git a/src/libs/Notification/PushNotification/subscribeToReportCommentPushNotifications.ts b/src/libs/Notification/PushNotification/subscribeToReportCommentPushNotifications.ts index 7f86d3ddb9ac..71f68d69acc7 100644 --- a/src/libs/Notification/PushNotification/subscribeToReportCommentPushNotifications.ts +++ b/src/libs/Notification/PushNotification/subscribeToReportCommentPushNotifications.ts @@ -12,7 +12,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {OnyxUpdatesFromServer} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; -import backgroundRefresh from './backgroundRefresh'; import PushNotification from './index'; let lastVisitedPath: string | undefined; @@ -51,8 +50,6 @@ export default function subscribeToReportCommentPushNotifications() { } else { Log.hmmm("[PushNotification] Didn't apply onyx updates because some data is missing", {lastUpdateID, previousUpdateID, onyxDataCount: onyxData?.length ?? 0}); } - - backgroundRefresh(); }); // Open correct report when push notification is clicked