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.
Copy file name to clipboardExpand all lines: README.md
+33-39Lines changed: 33 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -58,25 +58,6 @@ Having a problem? Read the [troubleshooting](./trouble-shooting.md) guide before
58
58
59
59
The component uses PushNotificationIOS for the iOS part. You should follow their [installation instructions](https://github.com/react-native-community/react-native-push-notification-ios).
60
60
61
-
When done, modify the following method in the file `AppDelegate.m`:
62
-
```objective-c
63
-
// Called when a notification is delivered to a foreground app.
**NOTE: `firebase-messaging`, prior to version 15 requires to have the same version number in order to work correctly at build time and at run time. To use a specific version:**
@@ -142,6 +123,17 @@ In `android/app/src/main/res/values/colors.xml` (Create the file if it doesn't e
142
123
</resources>
143
124
```
144
125
126
+
If your app has an @Override on onNewIntent in `MainActivity.java` ensure that function includes a super call on onNewIntent (if your `MainActivity.java` does not have an @Override for onNewIntent skip this):
127
+
128
+
```java
129
+
@Override
130
+
publicvoid onNewIntent(Intent intent) {
131
+
...
132
+
super.onNewIntent(intent);
133
+
...
134
+
}
135
+
```
136
+
145
137
### If you use remote notifications
146
138
147
139
Make sure you have installed setup Firebase correctly.
@@ -217,10 +209,10 @@ public class MainApplication extends Application implements ReactApplication {
217
209
@Override
218
210
protectedList<ReactPackage>getPackages() {
219
211
220
-
returnArrays.<ReactPackage>asList(
221
-
newMainReactPackage(),
222
-
newReactNativePushNotificationPackage() // <---- Add the Package
223
-
);
212
+
returnArrays.<ReactPackage>asList(
213
+
newMainReactPackage(),
214
+
newReactNativePushNotificationPackage() // <---- Add the Package
215
+
);
224
216
}
225
217
};
226
218
@@ -411,14 +403,16 @@ In the location notification json specify the full file name:
411
403
To use channels, create them at startup and pass the matching `channelId` through to `PushNotification.localNotification` or `PushNotification.localNotificationSchedule`.
channelDescription:"A channel to categorise your notifications", // (optional) default: undefined.
419
413
playSound:false, // (optional) default: true
420
414
soundName:"default", // (optional) See `soundName` parameter of `localNotification` function
421
-
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
422
416
vibrate:true, // (optional) default: true. Creates the default vibration patten if true.
423
417
},
424
418
(created) =>console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
@@ -598,10 +592,10 @@ Returns an array of local scheduled notification objects containing:
598
592
599
593
Available options:
600
594
601
-
"max" = NotficationCompat.PRIORITY_MAX
602
-
"high" = NotficationCompat.PRIORITY_HIGH
603
-
"low" = NotficationCompat.PRIORITY_LOW
604
-
"min" = NotficationCompat.PRIORITY_MIN
595
+
"max" = NotficationCompat.PRIORITY_MAX\
596
+
"high" = NotficationCompat.PRIORITY_HIGH\
597
+
"low" = NotficationCompat.PRIORITY_LOW\
598
+
"min" = NotficationCompat.PRIORITY_MIN\
605
599
"default" = NotficationCompat.PRIORITY_DEFAULT
606
600
607
601
More information: https://developer.android.com/reference/android/app/Notification.html#PRIORITY_DEFAULT
@@ -612,25 +606,25 @@ More information: https://developer.android.com/reference/android/app/Notificati
612
606
613
607
Available options:
614
608
615
-
"private" = NotficationCompat.VISIBILITY_PRIVATE
616
-
"public" = NotficationCompat.VISIBILITY_PUBLIC
617
-
"secret" = NotficationCompat.VISIBILITY_SECRET
609
+
"private" = NotficationCompat.VISIBILITY_PRIVATE\
610
+
"public" = NotficationCompat.VISIBILITY_PUBLIC\
611
+
"secret" = NotficationCompat.VISIBILITY_SECRET
618
612
619
613
More information: https://developer.android.com/reference/android/app/Notification.html#VISIBILITY_PRIVATE
620
614
621
615
## Notification importance
622
616
623
-
(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';`
@@ -30,7 +30,7 @@ export default class NotifService {
30
30
channelName: `Default channel`,// (required)
31
31
channelDescription: "A default channel",// (optional) default: undefined.
32
32
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
34
34
vibrate: true,// (optional) default: true. Creates the default vibration patten if true.
35
35
},
36
36
(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 {
41
41
channelName: `Sound channel`,// (required)
42
42
channelDescription: "A sound channel",// (optional) default: undefined.
43
43
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
45
45
vibrate: true,// (optional) default: true. Creates the default vibration patten if true.
46
46
},
47
47
(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 {
channelDescription: `A custom channel to categorise your custom notifications. Updated at: ${Date.now()}`,// (optional) default: undefined.
58
58
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
60
60
vibrate: true,// (optional) default: true. Creates the default vibration patten if true.
61
61
},
62
62
(created)=>console.log(`createChannel returned '${created}'`)// (optional) callback returns whether the channel was created, false means it already existed.
0 commit comments