[Office Hours] SpeziScheduler - scheduling and deleting notifications #146
-
Related DiscussionHi CS 342 Staff! @PSchmiedmayer , I'd like to ask a question related to the Currently, I schedule a weekly notification in our scheduler's configure method at 9 AM every Saturday and Sunday, reminding the user to log their weight in the app. If the user logs their weight on Saturday before the 9 AM notification, or after the 9 AM notification and before the Sunday 9 AM notification, I delete the remaining notifications for the current weekend. I do this by querying for these notifications by their ids with the When I delete the remaining notifications for the current weekend, will the scheduler still automatically schedule notifications for the following weekends as originally configured? Or does deleting a scheduled task remove it entirely, requiring me to re-schedule it post-deletion to ensure future notifications are still created? Thanks! ReproductionN/A Additional contextNo response Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
@lukaskollmer @Supereg Would you be able to answer this question? |
Beta Was this translation helpful? Give feedback.
-
@kkellybonilla based on your description, there's 2 issues here i think. Let's, for now, ignore the fact that you have two tasks, and assume that only the saturday-one exists. Firstly: when you call To give a broad overview of the module (sorry in advance if you already know this and i'm just explaining to you things you're already familiar with; IMO the explanation might still be useful for someone else in the future). SpeziScheduler consists of the following key components:
Tasks can optionally schedule notifications. In this case, even though you enable the notifications on a per-task level, they are actually scheduled on a per-event level: if you have a daily task, you have that single task in the scheduler, which then results in multiple events (one per day), and the scheduler will create one notification per event. This is where you're going wrong, i think: deleting a task will delete all of its events, which in turn will of course also cancel all of the associated notifications. The second issue, and this isn't your fault but IMO rather a deficiency in the current version of SpeziScheduler, is that currently, every Event can have at most a single notification. Your intended use case of having two notifications per event simply cannot be expressed using the current Scheduler APIs. IMO, there should be an API that lets you specify that you want multiple notifications per event, but we currently don't have that. |
Beta Was this translation helpful? Give feedback.
@kkellybonilla based on your description, there's 2 issues here i think.
Let's, for now, ignore the fact that you have two tasks, and assume that only the saturday-one exists.
Firstly: when you call
deleteTasks
, you're not deleting the upcoming notifications, but instead you delete the whole Task from the scheduler (which makes it appear as though you deleted the notifications, since deleting a Task will of course also delete all of its upcoming notifications).To give a broad overview of the module (sorry in advance if you already know this and i'm just explaining to you things you're already familiar with; IMO the explanation might still be useful for someone else in the future).
SpeziS…