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

Commit 83dc15d

Browse files
author
Henrique Shiraiwa
committed
Fix example app cancel notification
The `lastId` should reflect the last id used not the next id to be used. When the lastId is set to the next id to be used the `cancelNotif` function will try to cancel a id not yet used.
1 parent aaf2d19 commit 83dc15d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

example/NotifService.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export default class NotifService {
4040
}
4141

4242
localNotif() {
43+
this.lastId++;
4344
PushNotification.localNotification({
4445
/* Android Only Properties */
4546
id: ''+this.lastId, // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID
@@ -69,11 +70,10 @@ export default class NotifService {
6970
number: '10', // (optional) Valid 32 bit integer specified as string. default: none (Cannot be zero)
7071
actions: '["Yes", "No"]', // (Android only) See the doc for notification actions to know more
7172
});
72-
73-
this.lastId++;
7473
}
7574

7675
scheduleNotif() {
76+
this.lastId++;
7777
PushNotification.localNotificationSchedule({
7878
date: new Date(Date.now() + (30 * 1000)), // in 30 secs
7979

@@ -103,8 +103,6 @@ export default class NotifService {
103103
playSound: true, // (optional) default: true
104104
soundName: 'default', // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
105105
});
106-
107-
this.lastId++;
108106
}
109107

110108
checkPermission(cbk) {

0 commit comments

Comments
 (0)