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
Copy file name to clipboardExpand all lines: README.md
+36-30Lines changed: 36 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,7 +116,7 @@ dependencies {
116
116
</manifest>
117
117
```
118
118
119
-
> The `RECEIVE_BOOT_COMPLETED` permission is used to re-register all scheduled notifications after reboot.
119
+
> The `RECEIVE_BOOT_COMPLETED` permission is used to re-register all scheduled notifications after reboot.
120
120
> Requesting `VIBRATE` permission is required if you want to make the device vibrate while sending notifications.
121
121
122
122
- Edit `MainActivity.java` (usually at `android/app/src/main/java/com/<project-name>/MainActivity.java`) and add the annoated lines as below:
@@ -177,37 +177,37 @@ All available options on a notification are listed below:
177
177
178
178
#### Basic
179
179
180
-
**id (`number`)**
180
+
**id (`number`)**
181
181
The unique ID of this notification. It will be randomly chosen if not specified.
182
182
183
-
**subject (`string`)**
183
+
**subject (`string`)**
184
184
The notification subject. Defaults to the application name on Android.
185
185
186
-
**message (`string`)**
186
+
**message (`string`)**
187
187
The message showen in the notification.
188
188
189
-
**action (`string`)**
189
+
**action (`string`)**
190
190
An action name that can be used to determine what to do when this notification is clicked. Defaults to `DEFAULT`.
191
191
192
-
**payload (`object`)**
192
+
**payload (`object`)**
193
193
A custom payload object. It can be retrieved on events of this notification. Defaults to `{}`.
194
194
195
195
196
196
#### Scheduling
197
197
198
-
**delay (`number`)**
198
+
**delay (`number`)**
199
199
Milliseconds to delay before showing this notification after it is created. Useful when creating countdown alarms, reminders, etc. Note that it cannot be used with `sendAt`.
200
200
201
-
**sendAt (`Date`)**
201
+
**sendAt (`Date`)**
202
202
Schedule this notification to show on a specified time. Note that it cannot be used with `delay`.
203
203
204
-
**repeatEvery (`string` or `number`)**
204
+
**repeatEvery (`string` or `number`)**
205
205
Must use with `sendAt`. Schedule this notification to repeat. Can be `minute`, `hour`, `halfDay`, `day`, `week`, `month`, `year` or a number of time in milliseconds.
206
206
207
-
**repeatCount (`number`)**
207
+
**repeatCount (`number`)**
208
208
Must use with `sendAt` and `repeatEvery`. End repeating this notification after n times. Note that it cannot be used with `endAt`.
209
209
210
-
**endAt (`Date`)**
210
+
**endAt (`Date`)**
211
211
Must use with `sendAt` and `repeatEvery`. End repeating this notification after a specified time. Note that it cannot be used with `repeatCount`.
212
212
213
213
@@ -243,61 +243,61 @@ Must use with `sendAt` and `repeatEvery`. End repeating this notification after
243
243
244
244
#### Customization
245
245
246
-
**priority (`number`)**
246
+
**priority (`number`)**
247
247
Priority of this notification, can be `-2`, `-1`, `0`, `1`, `2`. When this is set to `1` or `2`, heads-up notification will be more likely to show on Android 5+. Defaults to `1`.
248
248
249
-
**smallIcon (`string`)**
249
+
**smallIcon (`string`)**
250
250
Theicon (filename) to show. This icon must be placed in the project's `android/app/src/main/res/mipmap-*` folder. Defaults to `ic_launcher`.
251
251
252
-
**largeIcon (`string`)**
252
+
**largeIcon (`string`)**
253
253
Not yet implemented.
254
254
255
-
**sound (`string`)**
255
+
**sound (`string`)**
256
256
Set the sound to play. Defaults to `default` as using the default notification sound, or set this to `null` to disable the sound. Other options are not yet implemented.
257
257
258
-
**vibrate (`string`)**
258
+
**vibrate (`string`)**
259
259
Set the vibration pattern to use. Defaults to `default` as using the default notification vibrate, or set this to `null` to disable the vibrate. Other options are not yet implemented.
260
260
261
-
**lights (`string`)**
261
+
**lights (`string`)**
262
262
Set the desired color for the indicator LED on the device. Defaults to `default` as using the default notification lights, or set this to `null` to disable the lights. Other options are not yet implemented.
263
263
264
-
**autoClear (`boolean`)**
264
+
**autoClear (`boolean`)**
265
265
Clear this notification automatically after the user clicks on it. Defaults to `true`.
266
266
267
-
**onlyAlertOnce (`boolean`)**
267
+
**onlyAlertOnce (`boolean`)**
268
268
Do not let the sound, vibrate and ticker to be played if the notification is already showing.
269
269
270
-
**tickerText (`string`)**
270
+
**tickerText (`string`)**
271
271
Set the text to show on ticker. Defaults to `<subject>: <message>`. Set this to `null` to disable ticker.
272
272
273
-
**when (`Date`)**
273
+
**when (`Date`)**
274
274
Add a timestamp pertaining to the notification (usuallythetimetheeventoccurred).
275
275
276
-
**bigText (`string`)**
276
+
**bigText (`string`)**
277
277
Set the text to be shown when the user expand the notification.
278
278
279
-
**subText (`string`)**
279
+
**subText (`string`)**
280
280
Set the third line of text in the platform notification template. Note that it cannot be used with `progress`.
281
281
282
-
**progress (`number`)**
282
+
**progress (`number`)**
283
283
Set the progress this notification represents, range: `0.0` ~ `1.0`. Set this to a number lower then zero to get an indeterminate progress. Note that it cannot be used with `subText`.
284
284
285
-
**color (`string`)**
285
+
**color (`string`)**
286
286
Color to be applied by the standard Style templates when presenting this notification.
287
287
288
-
**number (`number`)**
288
+
**number (`number`)**
289
289
Set a number on the notification.
290
290
291
-
**private (`boolean`)**
291
+
**private (`boolean`)**
292
292
Not yet implemented.
293
293
294
-
**ongoing (`boolean`)**
294
+
**ongoing (`boolean`)**
295
295
Not yet implemented.
296
296
297
-
**category (`string`)**
297
+
**category (`string`)**
298
298
Set the notification category, e.g.: `alarm`, `call`, `email`, `event`, `progress`, `reminder`, `social`. It may be used by the Android system for ranking and filtering.
299
299
300
-
**localOnly (`boolean`)**
300
+
**localOnly (`boolean`)**
301
301
Set whether or not this notification should not bridge to other devices.
Once you no longer need to listen to `sysNotificationClick` events de-register the listener functions with:
334
+
335
+
```js
336
+
Notification.removeAllListeners('press');
337
+
```
338
+
333
339
### ManageScheduledNotifications
334
340
335
341
Sometimes you'll need to get the scheduled notifications (which has `delay` or `sendAt` set up) that you had created before. You can use `Notification.getIDs()` to retrieve an array of IDs of available (i.e. will be send in the future) scheduled notifications.
0 commit comments