forked from katzer/cordova-plugin-local-notifications
-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
A notification shceduled for every hour sets up a second notification for 10 minutes later when triggered. The second notification is triggered, but not displayed.
cordova.plugins.notification.local.addActions('iwa-mode', [
{ id: 'okay', title: "I'm Okay" },
{ id: 'stop', title: "Stop Lone Worker Mode" }
]);
cordova.plugins.notification.local.schedule({
id: 1,
priority: 1,
title: 'Lone Worker',
text: 'Please confirm you are okay?',
actions: 'iwa-mode',
vibrate: true,
foreground: true,
autoClear: false,
trigger: { every: 'hour' }
});
cordova.plugins.notification.local.on('trigger', function (obj) {
if (obj.id == 1) {
cordova.plugins.notification.local.schedule({
id: 2,
title: 'Alert',
priority: 2,
text: 'No okay confirmation for 10 minutes\nAlert Triggered',
actions: 'iwa-mode',
vibrate: true,
foreground: true,
autoClear: false,
trigger: { in: 10, unit: 'minute' }
});
}
if (obj.id == 2) {
console.log('Triggering Alert!');
app.alertProcedure();
}
});
cordova.plugins.notification.local.on('okay', function () {
cordova.plugins.notification.local.cancel(2);
});
cordova.plugins.notification.local.on('okay', function () {
cordova.plugins.notification.local.cancelAll();
});
Your Environment
- Plugin version: 0.9-beta.3
- Platform: Android
- OS version: 9
- Device manufacturer / model: Motorola Moto G7
- Cordova version (
cordova -v): 9.0 - Cordova platform version (
cordova platform ls): 8.0 - Plugin config
- Ionic Version (if using Ionic)
Expected Behavior
The second notification should be displayed and a sound played.
Actual Behavior
The second notification is triggered at the appropriate time, but not displayed. However, the device vibrates if the app is in the background, but not when in the foreground.
Steps to Reproduce
- Schedule a repeating notification for every hour with id:1
- In the trigger event, if the id is 1, schedule a notification in 10 minutes with id:2
- If the first notification is clicked, cancel the notification with id:2
- If the first notification is not clicked within 10 minutes, the second notification should be displayed
Context
This is part of a 'lone worker' app which requires the user to confirm they are okay every hour, which is done by clicking on the repeating notification. If they don't respond within 10 minutes, the second notiification is triggered and an alert procedure is called.
Debug logs
Include iOS / Android logs
- ios XCode logs
- Android: $ adb logcat
Metadata
Metadata
Assignees
Labels
No labels