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

Commit 89303a0

Browse files
committed
Update documentation for new IMPORTANCE constant
Additionally add line breaks for visibility and priority options
1 parent a17a464 commit 89303a0

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -403,14 +403,16 @@ In the location notification json specify the full file name:
403403
To use channels, create them at startup and pass the matching `channelId` through to `PushNotification.localNotification` or `PushNotification.localNotificationSchedule`.
404404

405405
```javascript
406+
import PushNotification, {Importance} from 'react-native-push-notification';
407+
...
406408
PushNotification.createChannel(
407409
{
408410
channelId: "channel-id", // (required)
409411
channelName: "My channel", // (required)
410412
channelDescription: "A channel to categorise your notifications", // (optional) default: undefined.
411413
playSound: false, // (optional) default: true
412414
soundName: "default", // (optional) See `soundName` parameter of `localNotification` function
413-
importance: 4, // (optional) default: 4. Int value of the Android notification importance
415+
importance: Importance.HIGH, // (optional) default: Importance.HIGH. Int value of the Android notification importance
414416
vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
415417
},
416418
(created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
@@ -590,10 +592,10 @@ Returns an array of local scheduled notification objects containing:
590592

591593
Available options:
592594

593-
"max" = NotficationCompat.PRIORITY_MAX
594-
"high" = NotficationCompat.PRIORITY_HIGH
595-
"low" = NotficationCompat.PRIORITY_LOW
596-
"min" = NotficationCompat.PRIORITY_MIN
595+
"max" = NotficationCompat.PRIORITY_MAX\
596+
"high" = NotficationCompat.PRIORITY_HIGH\
597+
"low" = NotficationCompat.PRIORITY_LOW\
598+
"min" = NotficationCompat.PRIORITY_MIN\
597599
"default" = NotficationCompat.PRIORITY_DEFAULT
598600

599601
More information: https://developer.android.com/reference/android/app/Notification.html#PRIORITY_DEFAULT
@@ -604,25 +606,25 @@ More information: https://developer.android.com/reference/android/app/Notificati
604606

605607
Available options:
606608

607-
"private" = NotficationCompat.VISIBILITY_PRIVATE
608-
"public" = NotficationCompat.VISIBILITY_PUBLIC
609-
"secret" = NotficationCompat.VISIBILITY_SECRET
609+
"private" = NotficationCompat.VISIBILITY_PRIVATE\
610+
"public" = NotficationCompat.VISIBILITY_PUBLIC\
611+
"secret" = NotficationCompat.VISIBILITY_SECRET
610612

611613
More information: https://developer.android.com/reference/android/app/Notification.html#VISIBILITY_PRIVATE
612614

613615
## Notification importance
614616

615-
(optional) Specify `importance` to set importance of notification. Default value: "high"
617+
(optional) Specify `importance` to set importance of notification. Default value: Importance.HIGH
618+
Constants available on the `Importance` object. `import PushNotification, {Importance} from 'react-native-push-notification';`
616619

617620
Available options:
618621

619-
"default" = NotificationManager.IMPORTANCE_DEFAULT
620-
"max" = NotificationManager.IMPORTANCE_MAX
621-
"high" = NotificationManager.IMPORTANCE_HIGH
622-
"low" = NotificationManager.IMPORTANCE_LOW
623-
"min" = NotificationManager.IMPORTANCE_MIN
624-
"none" = NotificationManager.IMPORTANCE_NONE
625-
"unspecified" = NotificationManager.IMPORTANCE_UNSPECIFIED
622+
Importance.DEFAULT = NotificationManager.IMPORTANCE_DEFAULT\
623+
Importance.HIGH = NotificationManager.IMPORTANCE_HIGH\
624+
Importance.LOW = NotificationManager.IMPORTANCE_LOW\
625+
Importance.MIN = NotificationManager.IMPORTANCE_MIN\
626+
Importance.NONE= NotificationManager.IMPORTANCE_NONE\
627+
Importance.UNSPECIFIED = NotificationManager.IMPORTANCE_UNSPECIFIED
626628

627629
More information: https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_DEFAULT
628630

example/NotifService.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import PushNotification from 'react-native-push-notification';
1+
import PushNotification, {Importance} from 'react-native-push-notification';
22
import NotificationHandler from './NotificationHandler';
33

44
export default class NotifService {
@@ -30,7 +30,7 @@ export default class NotifService {
3030
channelName: `Default channel`, // (required)
3131
channelDescription: "A default channel", // (optional) default: undefined.
3232
soundName: "default", // (optional) See `soundName` parameter of `localNotification` function
33-
importance: 4, // (optional) default: 4. Int value of the Android notification importance
33+
importance: Importance.HIGH, // (optional) default: Importance.HIGH. Int value of the Android notification importance
3434
vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
3535
},
3636
(created) => console.log(`createChannel 'default-channel-id' returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
@@ -41,7 +41,7 @@ export default class NotifService {
4141
channelName: `Sound channel`, // (required)
4242
channelDescription: "A sound channel", // (optional) default: undefined.
4343
soundName: "sample.mp3", // (optional) See `soundName` parameter of `localNotification` function
44-
importance: 4, // (optional) default: 4. Int value of the Android notification importance
44+
importance: Importance.HIGH, // (optional) default: Importance.HIGH. Int value of the Android notification importance
4545
vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
4646
},
4747
(created) => console.log(`createChannel 'sound-channel-id' returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
@@ -56,7 +56,7 @@ export default class NotifService {
5656
channelName: `Custom channel - Counter: ${this.lastChannelCounter}`, // (required)
5757
channelDescription: `A custom channel to categorise your custom notifications. Updated at: ${Date.now()}`, // (optional) default: undefined.
5858
soundName: "default", // (optional) See `soundName` parameter of `localNotification` function
59-
importance: 4, // (optional) default: 4. Int value of the Android notification importance
59+
importance: Importance.HIGH, // (optional) default: Importance.HIGH. Int value of the Android notification importance
6060
vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
6161
},
6262
(created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.

0 commit comments

Comments
 (0)