Documentation for repeating notification is misleading
See original GitHub issueYour Environment
- Plugin version: 0.9.0-beta.1
- Platform: Android
- OS version: 6.0.1
- Device manufacturer / model: Motorola Moto X Play
- Cordova version (
cordova -v
): 7.1.0 - Cordova platform version (
cordova platform ls
): 6.3.0 - Plugin config: default
- Ionic Version (if using Ionic): 3.19.0
Expected Behavior
A notification should appear every 3 minutes.
Actual Behavior
A notification appear after 3 minutes, I manually remove it from the notification bar, and no other notification appear after more 3 minutes.
Steps to Reproduce
- Schedule a notification with this code:
cordova.plugins.notification.local.schedule({ id: 10, icon: 'file://assets/imgs/logo.png', title: 'Test Title', text: 'Test description', trigger: { unit: 'minute', every: 3 } });
- Wait 3 minutes
- Remove notification manually
- Wait another 3 minutes
- Nothing happens
Context
I was trying to make some kind of an alarm, customized by the user. I think my problem is the repeat structute on the options object. Documentation is misleading. Here (https://github.com/katzer/cordova-plugin-local-notifications#properties-2) it says to use “every” and “count” inside a “trigger” property. I don’t know what count does, too. Here (https://github.com/katzer/cordova-plugin-local-notifications/wiki/04.-Scheduling#interface) it says to use every, without trigger object. In a closed issue I found this “trigger: { any: ‘minute’, every: 3 }” and thought it was right, but looks like it doesn’t work too.
What is the correct way to repeat an notification? Documentation should be consistent.
Debug logs
Couldn’t filter logs.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top GitHub Comments
Check the Background Mode plugin (from Katzer too). Then mix with the Local Notification plugin.
this.repeticaoAgua = setInterval(function(){ this.localNotifications.schedule({ id: 1, icon: 'res/iconred.png', title: 'Hora de tomar água!' }); }.bind(this), (60000));
I putted the interval on a var to cancel it if when I want
cancelAguaNotification(){ clearInterval(this.repeticaoAgua); }
I tried with master using Android Emulator and Samsung and it worked as expected. Even I clear the notification it pops-up again after.
The relevant entry point in the code is here: https://github.com/katzer/cordova-plugin-local-notifications/blob/0.9.0-beta.1/src/android/ClearReceiver.java#L49