Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Implement removeAllDeliveredNotifications. #636

Conversation

amazingmarvin
Copy link

This function clears delivered notifications, but not scheduled local notifications. Since it's in react-native's PushNotificationIOS, adding it to react-native-push-notification brings us closer to feature parity. And this is a simple, but important one. See RN Docs.

The following code can be used to test this functionality:

import {
  AppState,
} from "react-native";

import PushNotification from "react-native-push-notification";

function clearNotifications() {
  const { currentState } = AppState;

  if (currentState === "active") {
    PushNotification.removeAllDeliveredNotifications();
  }
}

AppState.addEventListener("change", clearNotifications);
setTimeout(clearNotifications, 0);

This makes notifications clear on startup and when the app enters foreground. When you open the app, all notifications for the app in the notification center should disappear. To further test it, schedule a notification, then put the app in the background and then the foreground again. The scheduled notification should appear anyway. Canceling scheduled local notifications was a blocker for my app before this PR.

This PR addresses one point in #427. I may implement the other new features if I find a need for them.

walty8 pushed a commit to bartsolutions/react-native-push-notification that referenced this pull request Jan 9, 2019
@dnlsilva
Copy link

dnlsilva commented Sep 5, 2019

@zo0r merge these pull request, and release a new version.

@RichardNTran
Copy link

please merge it now.

@samaneh-kamalian
Copy link

samaneh-kamalian commented Jan 22, 2020

please merge it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants