@@ -24,11 +24,15 @@ Changelog is available from version 3.1.3 here: [Changelog](https://github.com/z
24
24
25
25
### NPM
26
26
27
- ` npm install --save react-native-push-notification `
27
+ ```
28
+ npm install --save react-native-push-notification
29
+ ```
28
30
29
31
### Yarn
30
32
31
- ` yarn add react-native-push-notification `
33
+ ```
34
+ yarn add react-native-push-notification
35
+ ```
32
36
33
37
** NOTE: If you target iOS you also need to follow the [ installation instructions for PushNotificationIOS] ( https://github.com/react-native-community/react-native-push-notification-ios ) since this package depends on it.**
34
38
@@ -293,7 +297,9 @@ Notification object example:
293
297
294
298
## Local Notifications
295
299
296
- ` PushNotification.localNotification(details: Object) `
300
+ ``` js
301
+ PushNotification .localNotification (details: Object )
302
+ ```
297
303
298
304
EXAMPLE:
299
305
@@ -353,7 +359,9 @@ PushNotification.localNotification({
353
359
354
360
## Scheduled Notifications
355
361
356
- ` PushNotification.localNotificationSchedule(details: Object) `
362
+ ``` js
363
+ PushNotification .localNotificationSchedule (details: Object )
364
+ ```
357
365
358
366
EXAMPLE:
359
367
@@ -371,7 +379,9 @@ PushNotification.localNotificationSchedule({
371
379
372
380
## Get the initial notification
373
381
374
- ` PushNotification.popInitialNotification(callback) `
382
+ ``` js
383
+ PushNotification .popInitialNotification (callback)
384
+ ```
375
385
376
386
EXAMPLE:
377
387
@@ -577,19 +587,24 @@ Returns an array of local scheduled notification objects containing:
577
587
578
588
## Abandon Permissions
579
589
580
- ` PushNotification.abandonPermissions() ` Revokes the current token and unregister for all remote notifications received via APNS or FCM.
590
+ ``` js
591
+ PushNotification .abandonPermissions ()
592
+ ```
593
+ Revokes the current token and unregister for all remote notifications received via APNS or FCM.
581
594
582
595
## Notification priority
583
596
584
597
(optional) Specify ` priority ` to set priority of notification. Default value: "high"
585
598
586
599
Available options:
587
600
601
+ ```
588
602
"max" = NotficationCompat.PRIORITY_MAX\
589
603
"high" = NotficationCompat.PRIORITY_HIGH\
590
604
"low" = NotficationCompat.PRIORITY_LOW\
591
605
"min" = NotficationCompat.PRIORITY_MIN\
592
606
"default" = NotficationCompat.PRIORITY_DEFAULT
607
+ ```
593
608
594
609
More information: https://developer.android.com/reference/android/app/Notification.html#PRIORITY_DEFAULT
595
610
@@ -599,10 +614,11 @@ More information: https://developer.android.com/reference/android/app/Notificati
599
614
600
615
Available options:
601
616
617
+ ```
602
618
"private" = NotficationCompat.VISIBILITY_PRIVATE\
603
619
"public" = NotficationCompat.VISIBILITY_PUBLIC\
604
620
"secret" = NotficationCompat.VISIBILITY_SECRET
605
-
621
+ ```
606
622
More information: https://developer.android.com/reference/android/app/Notification.html#VISIBILITY_PRIVATE
607
623
608
624
## Notification importance
@@ -611,13 +627,14 @@ More information: https://developer.android.com/reference/android/app/Notificati
611
627
Constants available on the ` Importance ` object. ` import PushNotification, {Importance} from 'react-native-push-notification'; `
612
628
613
629
Available options:
614
-
630
+ ```
615
631
Importance.DEFAULT = NotificationManager.IMPORTANCE_DEFAULT\
616
632
Importance.HIGH = NotificationManager.IMPORTANCE_HIGH\
617
633
Importance.LOW = NotificationManager.IMPORTANCE_LOW\
618
634
Importance.MIN = NotificationManager.IMPORTANCE_MIN\
619
635
Importance.NONE= NotificationManager.IMPORTANCE_NONE\
620
636
Importance.UNSPECIFIED = NotificationManager.IMPORTANCE_UNSPECIFIED
637
+ ```
621
638
622
639
More information: https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_DEFAULT
623
640
@@ -715,17 +732,25 @@ Documentation [here](https://github.com/react-native-push-notification-ios/push-
715
732
716
733
## Set application badge icon
717
734
718
- ` PushNotification.setApplicationIconBadgeNumber(number: number) `
735
+ ``` js
736
+ PushNotification .setApplicationIconBadgeNumber (number: number)
737
+ ```
719
738
720
739
Works natively in iOS.
721
740
722
741
Uses the [ ShortcutBadger] ( https://github.com/leolin310148/ShortcutBadger ) on Android, and as such will not work on all Android devices.
723
742
724
743
## Android Only Methods
725
744
726
- ` PushNotification.subscribeToTopic(topic: string) ` Subscribe to a topic (works only with Firebase)
745
+ ``` js
746
+ PushNotification .subscribeToTopic (topic: string)
747
+ ```
748
+ Subscribe to a topic (works only with Firebase)
727
749
728
- ` PushNotification.unsubscribeFromTopic(topic: string) ` Unsubscribe from a topic (works only with Firebase)
750
+ ``` js
751
+ PushNotification .unsubscribeFromTopic (topic: string)
752
+ ```
753
+ Unsubscribe from a topic (works only with Firebase)
729
754
730
755
## Android Custom Notification Handling
731
756
@@ -746,7 +771,7 @@ Data payloads of notifications from 3rd party services may not match the format
746
771
747
772
Custom handlers are added in Application init or ` MainActivity.onCreate() ` methods:
748
773
749
- ```
774
+ ``` java
750
775
RNPushNotification . IntentHandlers . add(new RNPushNotification .RNIntentHandler () {
751
776
@Override
752
777
public void onNewIntent (Intent intent ) {
@@ -772,7 +797,9 @@ RNPushNotification.IntentHandlers.add(new RNPushNotification.RNIntentHandler() {
772
797
773
798
## Checking Notification Permissions
774
799
775
- ` PushNotification.checkPermissions(callback: Function) ` Check permissions
800
+ ``` js
801
+ PushNotification .checkPermissions (callback: Function ) // Check permissions
802
+ ```
776
803
777
804
` callback ` will be invoked with a ` permissions ` object:
778
805
@@ -782,4 +809,7 @@ RNPushNotification.IntentHandlers.add(new RNPushNotification.RNIntentHandler() {
782
809
783
810
## iOS Only Methods
784
811
785
- ` PushNotification.getApplicationIconBadgeNumber(callback: Function) ` Get badge number
812
+ ``` js
813
+ PushNotification .getApplicationIconBadgeNumber (callback: Function ) // Get badge number
814
+ ```
815
+
0 commit comments