diff --git a/lib/ios/RCTConvert+RNNotifications.m b/lib/ios/RCTConvert+RNNotifications.m index 375046fc6..a7c74de4e 100644 --- a/lib/ios/RCTConvert+RNNotifications.m +++ b/lib/ios/RCTConvert+RNNotifications.m @@ -139,6 +139,11 @@ + (UNNotificationPresentationOptions)UNNotificationPresentationOptions:(id)json if ([RCTConvert BOOL:json[@"sound"]]) { options = options | UNNotificationPresentationOptionSound; } + if ([RCTConvert BOOL:json[@"list"]]) { + if (@available(iOS 14.0, *)) { + options = options | UNNotificationPresentationOptionList; + } + } return options; } diff --git a/lib/src/interfaces/NotificationCompletion.ts b/lib/src/interfaces/NotificationCompletion.ts index 17df69d5b..edb97e226 100644 --- a/lib/src/interfaces/NotificationCompletion.ts +++ b/lib/src/interfaces/NotificationCompletion.ts @@ -2,6 +2,7 @@ export interface NotificationCompletion { badge?: boolean; alert?: boolean; sound?: boolean; + list?: boolean; } export enum NotificationBackgroundFetchResult { diff --git a/website/docs/api/notification-obj.md b/website/docs/api/notification-obj.md index 68206fd1a..904171aec 100755 --- a/website/docs/api/notification-obj.md +++ b/website/docs/api/notification-obj.md @@ -15,12 +15,19 @@ Contains the payload data. - **`category`**- returns the category from the `aps` object (related to interactive notifications). - **`payload`**- returns the full payload sent from server. +### Notification Completion +When handling a notification you should call the completion handler with the following object: +- **`alert`**- boolean (default: false). Wether to show the notification alert. +- **`sound`**- boolean (default: false). Wether to play the notification sound. +- **`badge`**- boolean (default: false). Wether to update the app badge. +- **`list`**- boolean (default: false). Wether to show the notification in the notification center (iOS 14+). + Example: ```js Notifications.events().registerNotificationReceivedForeground((notification: Notification, completion: (response: NotificationCompletion) => void) => { // Prints the notification payload console.log(JSON.stringify(notification.payload)); - completion({alert: false, sound: false, badge: false}); + completion({alert: false, sound: false, badge: false, list: false}); }); ``` \ No newline at end of file diff --git a/website/docs/docs/getting-started.md b/website/docs/docs/getting-started.md index 8e5326ed0..11946696a 100644 --- a/website/docs/docs/getting-started.md +++ b/website/docs/docs/getting-started.md @@ -96,7 +96,7 @@ class MyComponent extends Component { Notifications.events().registerNotificationReceivedForeground((notification: Notification, completion) => { console.log(`Notification received in foreground: ${notification.title} : ${notification.body}`); - completion({alert: false, sound: false, badge: false}); + completion({alert: false, sound: false, badge: false, list: false}); }); Notifications.events().registerNotificationOpened((notification: Notification, completion) => {