Skip to content
Open
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
5 changes: 5 additions & 0 deletions lib/ios/RCTConvert+RNNotifications.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions lib/src/interfaces/NotificationCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface NotificationCompletion {
badge?: boolean;
alert?: boolean;
sound?: boolean;
list?: boolean;
}

export enum NotificationBackgroundFetchResult {
Expand Down
9 changes: 8 additions & 1 deletion website/docs/api/notification-obj.md
Original file line number Diff line number Diff line change
Expand Up @@ -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});
});
```
2 changes: 1 addition & 1 deletion website/docs/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down