Closed srowe0091 closed 4 years ago
does anyone else experience this, or am i the only one?
You can save the id somewhere else and use that to cancel later... The following worked for me (ignore "second" and "count", since "second" seems bugged and the same as "minutes" and "count" does not seem to do anything)
async onNotification()
{
if(!await LocalNotifications.areEnabled())
{
alert('Local notifications not enabled.');
}
else
{
let notification: LocalNotification = {
body: 'This is a fine SkekNot',
id: 1,
title: 'Skekification!',
sound: null,
schedule: {
repeats: true,
every: "second",
count: 10
},
};
const result = await LocalNotifications.schedule({
notifications: [ notification ]
});
}
}
async onCancelNotification()
{
await LocalNotifications.cancel({
notifications: [
{ id: "1"}
]
});
}
Why one is passed as a number and the other as a string?... well... ask the people who designed this...
I've been able to reproduce, but was removed from the pending list if dismissed, not right after being triggered or if tapped. Fixed that in https://github.com/ionic-team/capacitor/pull/2809
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.
Bug Report
Capacitor Version
npx cap doctor
output:Affected Platform(s)
Current Behavior
A notification that is set with the property "every" has no way of being turned off because the pending notification gets removed as soon as the first notification is triggered. Therefore losing reference to the notifications and never being able to cancel it
Expected Behavior
Have some sort of reference to active/triggered notifications that are repeated in order to properly remove them by some function/setting change.
For example, a notification that appears weekly, and allowing the user, in the app, to turn off notifications whenever they want to.
Sample Code or Sample Application Repo
Reproduction Steps
calling this function
will log the output
as soon as notification is triggered, logging the list of notifications is now an empty array. I understand the function is to getPending, so maybe another function should be provided for retrieving triggered, repeatable, notifications, so they can be cancelled
Other Technical Details
npm --version
output: 6.14.2node --version
output: 13.6.0Other Information
Also, would be useful if the documentation provided a little more clarity on how to use notifications better with different scenarios.