You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
channelId:"your-custom-channel-id", // (optional) custom channelId, if the channel doesn't exist, it will be created with options passed above (importance, vibration, sound). Once the channel is created, the channel will not be update. Make sure your channelId is different if you change these options. If you have created a custom channel, it will apply options of the channel.
303
314
304
315
actions:'["Yes", "No"]', // (Android only) See the doc for notification actions to know more
316
+
invokeApp:true, // (optional) This enable click on actions to bring back the application to foreground or stay in background, default: true
305
317
306
318
/* iOS only properties */
307
319
alertAction:"view", // (optional) default: view
@@ -349,13 +361,21 @@ This library doesn't include a full Channel Management at the moment. Channels a
349
361
The pattern of `channel_id` is:
350
362
351
363
```
352
-
rn-push-notification-channel-id(-soundname, default if playSound "-default")-(importance: default "4")-(vibration, default "300")
364
+
rn-push-notification-channel-id-(importance: default "4")(-soundname, default if playSound "-default")-(vibration, default "300")
353
365
```
354
366
355
-
By default, 2 channels are created:
367
+
By default, 1 channel is created:
368
+
369
+
- rn-push-notification-channel-id-4-default-300 (used for remote notification if none already exist).
- rn-push-notification-channel-id-default-4-300 (used for remote notification if none already exist).
358
-
- rn-push-notification-channel-id-4-300 (previously used for remote notification but without sounds).
378
+
**NOTE: Without channel, remote notifications don't work**
359
379
360
380
In the notifications options, you can provide a custom channel id with `channelId: "your-custom-channel-id"`, if the channel doesn't exist, it will be created with options passed above (importance, vibration, sound). Once the channel is created, the channel will not be update. Make sure your `channelId` is different if you change these options. If you have created a custom channel in another way, it will apply options of the channel.
361
381
@@ -387,6 +407,37 @@ If you want to use a different default channel for remote notification, refer to
@@ -539,38 +590,11 @@ Property `repeatType` could be one of `month`, `week`, `day`, `hour`, `minute`,
539
590
540
591
(Android only) [Refer](https://github.com/zo0r/react-native-push-notification/issues/151) to this issue to see an example of a notification action.
541
592
542
-
Two things are required to setup notification actions.
543
-
544
-
### 1) Specify notification actions for a notification
545
-
546
593
This is done by specifying an `actions` parameters while configuring the local notification. This is an array of strings where each string is a notification action that will be presented with the notification.
547
594
548
-
For e.g. `actions: '["Accept", "Reject"]' // Must be in string format`
549
-
550
-
The array itself is specified in string format to circumvent some problems because of the way JSON arrays are handled by react-native android bridge.
551
-
552
-
### 2) Specify handlers for the notification actions
595
+
For e.g. `actions: ['Accept', 'Reject']`
553
596
554
-
For each action specified in the `actions` field, we need to add a handler that is called when the user clicks on the action. This can be done in the `componentWillMount` of your main app file or in a separate file which is imported in your main app file. Notification actions handlers can be configured as below:
555
-
556
-
```
557
-
import PushNotificationAndroid from 'react-native-push-notification'
558
-
559
-
(function() {
560
-
// Register all the valid actions for notifications here and add the action handler for each action
When you handle actions in background (`invokeApp: false`), you can open the application and pass the initial notification by using use `PushNotification.invokeApp(notification)`.
574
598
575
599
For iOS, you can use this [package](https://github.com/holmesal/react-native-ios-notification-actions) to add notification actions.
0 commit comments