Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,6 @@ const ONYXKEYS = {
/** The NVP containing the target url to navigate to when deleting a transaction */
NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URL: 'nvp_deleteTransactionNavigateBackURL',

/** Does this user have push notifications enabled for this device? */
PUSH_NOTIFICATIONS_ENABLED: 'pushNotificationsEnabled',

/** Plaid data (access tokens, bank accounts ...) */
PLAID_DATA: 'plaidData',

Expand Down Expand Up @@ -964,7 +961,6 @@ type OnyxValuesMapping = {
[ONYXKEYS.HAS_NON_PERSONAL_POLICY]: boolean;
[ONYXKEYS.NVP_LAST_SELECTED_DISTANCE_RATES]: OnyxTypes.LastSelectedDistanceRates;
[ONYXKEYS.NVP_SEEN_NEW_USER_MODAL]: boolean;
[ONYXKEYS.PUSH_NOTIFICATIONS_ENABLED]: boolean;
[ONYXKEYS.PLAID_DATA]: OnyxTypes.PlaidData;
[ONYXKEYS.IS_PLAID_DISABLED]: boolean;
[ONYXKEYS.PLAID_LINK_TOKEN]: string;
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export type {default as DisableTwoFactorAuthParams} from './DisableTwoFactorAuth
export type {default as VerifyIdentityForBankAccountParams} from './VerifyIdentityForBankAccountParams';
export type {default as AnswerQuestionsForWalletParams} from './AnswerQuestionsForWalletParams';
export type {default as AddCommentOrAttachementParams} from './AddCommentOrAttachementParams';
export type {default as OptInOutToPushNotificationsParams} from './OptInOutToPushNotificationsParams';
export type {default as ReadNewestActionParams} from './ReadNewestActionParams';
export type {default as MarkAsUnreadParams} from './MarkAsUnreadParams';
export type {default as TogglePinnedChatParams} from './TogglePinnedChatParams';
Expand Down
4 changes: 0 additions & 4 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ const WRITE_COMMANDS = {
ADD_PERSONAL_BANK_ACCOUNT: 'AddPersonalBankAccount',
RESTART_BANK_ACCOUNT_SETUP: 'RestartBankAccountSetup',
RESEND_VALIDATE_CODE: 'ResendValidateCode',
OPT_IN_TO_PUSH_NOTIFICATIONS: 'OptInToPushNotifications',
OPT_OUT_OF_PUSH_NOTIFICATIONS: 'OptOutOfPushNotifications',
READ_NEWEST_ACTION: 'ReadNewestAction',
MARK_AS_UNREAD: 'MarkAsUnread',
TOGGLE_PINNED_CHAT: 'TogglePinnedChat',
Expand Down Expand Up @@ -540,9 +538,7 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.CONNECT_BANK_ACCOUNT_WITH_PLAID]: Parameters.ConnectBankAccountParams;
[WRITE_COMMANDS.ADD_PERSONAL_BANK_ACCOUNT]: Parameters.AddPersonalBankAccountParams;
[WRITE_COMMANDS.RESTART_BANK_ACCOUNT_SETUP]: Parameters.RestartBankAccountSetupParams;
[WRITE_COMMANDS.OPT_IN_TO_PUSH_NOTIFICATIONS]: Parameters.OptInOutToPushNotificationsParams;
[WRITE_COMMANDS.RESEND_VALIDATE_CODE]: null;
[WRITE_COMMANDS.OPT_OUT_OF_PUSH_NOTIFICATIONS]: Parameters.OptInOutToPushNotificationsParams;
[WRITE_COMMANDS.READ_NEWEST_ACTION]: Parameters.ReadNewestActionParams;
[WRITE_COMMANDS.MARK_AS_UNREAD]: Parameters.MarkAsUnreadParams;
[WRITE_COMMANDS.TOGGLE_PINNED_CHAT]: Parameters.TogglePinnedChatParams;
Expand Down
8 changes: 0 additions & 8 deletions src/libs/E2E/utils/NetworkInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,6 @@ export default function installNetworkInterceptor(
const headers = getFetchRequestHeadersAsObject(options);
const url = fetchArgsGetUrl(args);

// Don't process these specific API commands because running them over and over again in the tests increases the size of the notificationPreferences NVP on the server to an infinite size.
// This is due to the NVP storing this setting once for each user's device, and since the E2E tests use AWS device farm, the user ends up with thousands of different devices,
// unlike normal users that might only ever have about a dozen. We found the NVP was over 2.5mb in size and that slows down database replication.
if (url.includes('OptInToPushNotifications') || url.includes('OptOutOfPushNotifications')) {
console.debug('Skipping request to opt in or out of push notifications');
return Promise.resolve(new Response());
}

// Check if headers contain any of the ignored headers, or if react native metro server:
if (IGNORE_REQUEST_HEADERS.some((header) => headers[header] != null) || url.includes('8081')) {
return originalFetch(...args);
Expand Down
30 changes: 0 additions & 30 deletions src/libs/Notification/PushNotification/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import type {PushPayload} from '@ua/react-native-airship';
import Airship, {EventType} from '@ua/react-native-airship';
import Onyx from 'react-native-onyx';
import Log from '@libs/Log';
import ShortcutManager from '@libs/ShortcutManager';
import * as PushNotificationActions from '@userActions/PushNotification';
import ONYXKEYS from '@src/ONYXKEYS';
import ForegroundNotifications from './ForegroundNotifications';
import type {PushNotificationData} from './NotificationType';
import NotificationType from './NotificationType';
Expand All @@ -16,12 +13,6 @@ type NotificationEventActionCallback = (data: PushNotificationData) => Promise<v

type NotificationEventActionMap = Partial<Record<EventType, Record<string, NotificationEventActionCallback>>>;

let isUserOptedInToPushNotifications = false;
Onyx.connect({
key: ONYXKEYS.PUSH_NOTIFICATIONS_ENABLED,
callback: (value) => (isUserOptedInToPushNotifications = value ?? false),
});

const notificationEventActionMap: NotificationEventActionMap = {};

/**
Expand Down Expand Up @@ -61,21 +52,6 @@ function pushNotificationEventCallback(eventType: EventType, notification: PushP
return action(data);
}

/**
* Check if a user is opted-in to push notifications on this device and update the `pushNotificationsEnabled` NVP accordingly.
*/
function refreshNotificationOptInStatus() {
Airship.push.getNotificationStatus().then((notificationStatus) => {
const isOptedIn = notificationStatus.isOptedIn && notificationStatus.areNotificationsAllowed;
if (isOptedIn === isUserOptedInToPushNotifications) {
return;
}

Log.info('[PushNotification] Push notification opt-in status changed.', false, {isOptedIn});
PushNotificationActions.setPushNotificationOptInStatus(isOptedIn);
});
}

/**
* Configure push notifications and register callbacks. This is separate from namedUser registration because it needs to be executed
* from a headless JS process, outside of any react lifecycle.
Expand All @@ -91,9 +67,6 @@ const init: Init = () => {
// so event.notification refers to the same thing as notification above ^
Airship.addListener(EventType.NotificationResponse, (event) => pushNotificationEventCallback(EventType.NotificationResponse, event.pushPayload));

// Keep track of which users have enabled push notifications via an NVP.
Airship.addListener(EventType.PushNotificationStatusChangedStatus, refreshNotificationOptInStatus);

ForegroundNotifications.configureForegroundNotifications();
};

Expand Down Expand Up @@ -122,9 +95,6 @@ const register: Register = (notificationID) => {
// Regardless of the user's opt-in status, we still want to receive silent push notifications.
Log.info(`[PushNotification] Subscribing to notifications`);
Airship.contact.identify(notificationID.toString());

// Refresh notification opt-in status NVP for the new user.
refreshNotificationOptInStatus();
})
.catch((error: Record<string, unknown>) => {
Log.warn('[PushNotification] Failed to register for push notifications! Reason: ', error);
Expand Down
45 changes: 0 additions & 45 deletions src/libs/actions/PushNotification.ts

This file was deleted.