From 970d7c0df536da777f7f63b720e9e2f3b30689d2 Mon Sep 17 00:00:00 2001 From: Jesse Katsumata Date: Thu, 26 Nov 2020 03:08:00 +0900 Subject: [PATCH] feat: add removePendingNotificationRequests method --- README.md | 20 +++++++++++++-- example/App.js | 47 ++++++++++++++++++++++++++++++++++++ index.d.ts | 5 ++++ ios/RNCPushNotificationIOS.m | 12 +++++++-- js/index.js | 13 +++++++++- 5 files changed, 92 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 66b1e6ab1..1ac090d68 100644 --- a/README.md +++ b/README.md @@ -354,6 +354,22 @@ Allows you to add specific actions for notification with specific category. --- +### `removePendingNotificationRequests()` + +```jsx +PushNotificationIOS.removeDeliveredNotifications(identifiers); +``` + +Removes the specified pending notifications from Notification Center + +**Parameters:** + +| Name | Type | Required | Description | +| ----------- | ----- | -------- | ---------------------------------- | +| identifiers | string[] | Yes | Array of notification identifiers. | + +--- + ### `removeAllPendingNotificationRequests()` ```jsx @@ -405,13 +421,13 @@ A delivered notification is an object containing: PushNotificationIOS.removeDeliveredNotifications(identifiers); ``` -Removes the specified notifications from Notification Center +Removes the specified delivered notifications from Notification Center **Parameters:** | Name | Type | Required | Description | | ----------- | ----- | -------- | ---------------------------------- | -| identifiers | array | Yes | Array of notification identifiers. | +| identifiers | string[] | Yes | Array of notification identifiers. | --- diff --git a/example/App.js b/example/App.js index 3862c5a79..dab832a0f 100644 --- a/example/App.js +++ b/example/App.js @@ -132,6 +132,41 @@ export const App = (): React.Node => { }); }; + const addMultipleRequests = () => { + PushNotificationIOS.addNotificationRequest({ + id: 'test-1', + title: 'First', + subtitle: 'subtitle', + body: 'First Notification out of 3', + category: 'test', + threadId: 'thread-id', + fireDate: new Date(new Date().valueOf() + 10000), + repeats: true, + }); + + PushNotificationIOS.addNotificationRequest({ + id: 'test-2', + title: 'Second', + subtitle: 'subtitle', + body: 'Second Notification out of 3', + category: 'test', + threadId: 'thread-id', + fireDate: new Date(new Date().valueOf() + 12000), + repeats: true, + }); + + PushNotificationIOS.addNotificationRequest({ + id: 'test-3', + title: 'Third', + subtitle: 'subtitle', + body: 'Third Notification out of 3', + category: 'test', + threadId: 'thread-id', + fireDate: new Date(new Date().valueOf() + 14000), + repeats: true, + }); + }; + const getPendingNotificationRequests = () => { PushNotificationIOS.getPendingNotificationRequests((requests) => { Alert.alert('Push Notification Received', JSON.stringify(requests), [ @@ -179,6 +214,10 @@ export const App = (): React.Node => { PushNotificationIOS.removeAllPendingNotificationRequests(); }; + const removePendingNotificationRequests = () => { + PushNotificationIOS.removePendingNotificationRequests(['test-1', 'test-2']); + }; + const onRegistered = (deviceToken) => { Alert.alert('Registered For Remote Push', `Device Token: ${deviceToken}`, [ { @@ -279,10 +318,18 @@ export const App = (): React.Node => { onPress={addNotificationRequest} label="Add Notification Request" /> +