Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear push notifications when logging out #4160

Merged
merged 3 commits into from
Jul 22, 2021
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
3 changes: 3 additions & 0 deletions src/Expensify.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class Expensify extends PureComponent {
// boot screen right away
if (!this.getAuthToken()) {
this.hideSplash();

// In case of a crash that led to disconnection, we want to remove all the push notifications.
PushNotification.clearNotifications();
}

this.setState({isOnyxMigrated: true});
Expand Down
1 change: 1 addition & 0 deletions src/libs/Notification/PushNotification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export default {
onReceived: () => {},
onSelected: () => {},
TYPE: NotificationType,
clearNotifications: () => {},
};
8 changes: 8 additions & 0 deletions src/libs/Notification/PushNotification/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,18 @@ function onSelected(notificationType, callback) {
bind(notificationType, callback, EventType.NotificationResponse);
}

/**
* Clear all push notifications
*/
function clearNotifications() {
UrbanAirship.clearNotifications();
}

export default {
register,
deregister,
onReceived,
onSelected,
TYPE: NotificationType,
clearNotifications,
};
1 change: 1 addition & 0 deletions src/libs/actions/SignInRedirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Onyx.connect({
function redirectToSignIn(errorMessage) {
UnreadIndicatorUpdater.stopListeningForReportChanges();
PushNotification.deregister();
PushNotification.clearNotifications();
Pusher.disconnect();
Timers.clearAll();

Expand Down