0

I have the following code to add a notification:

$cordovaLocalNotification.add({
                        id:"my-notification",
                        repeat:"daily",
                        date:time,
                        message:"a message"
                      });

But for some reason, when I run the code to cancel it:

cordova.plugin.notification.local.cancel("my-notification");

The notification isn't cleared. Nothing I do seems to clear the notification.

William Neely
  • 1,923
  • 1
  • 20
  • 23

2 Answers2

0

The local notification plugin requires that the IDs are Integers.

If they aren't, the plugin will silently use 0 as the id for the notification.

I'm not sure if this has changed recently because I feel like I've used string ids in the past.

If anyone knows of a plugin for mapping strings to integer ids, I would find that useful!

William Neely
  • 1,923
  • 1
  • 20
  • 23
0

Why don't you use a simple javascript object?

var notificationMap = {"my-notitifcation-1":1, "my-not-2":2, "my-not-x":3}

then get the id using:

notificationMap["my-notitifcation-1]
lifeisfoo
  • 15,478
  • 6
  • 74
  • 115