StanfordSpezi / SpeziScheduler

Scheduler Module for the Stanford Spezi Ecosystem
https://swiftpackageindex.com/StanfordSpezi/SpeziScheduler/documentation/
MIT License
4 stars 3 forks source link

Support for scheduling notifications #49

Closed Supereg closed 1 month ago

Supereg commented 2 months ago

Support for scheduling notifications

:recycle: Current situation & Problem

The newly introduced SpeziScheduler #44 didn't include support for notifications (see #45). This PR adds back this feature, providing several improvements over the previous implementation. A core challenge is that Apple limits the amount of locally scheduled notifications to 64 request at a time. Therefore, we optimize scheduling by applying the overall rules:

:gear: Release Notes

:books: Documentation

Added a dedicated configuration section around notifications in the documentation catalog. The documentation of the SchedulerNotifications module highlights the necessary steps to set up notifications for your project.

:white_check_mark: Testing

Added the XCTSpeziScheduler target that provide UI components to visualize scheduled notification requests. We use this in the UI tests to verify that notifications are scheduled as expected. The Test App schedules a repeating daily notification that has its first occurrence 40s after app launch. Additionally we schedule a daily repeating task that starts 1 week after initial app launch to test event-level scheduling.

:pencil: Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 69.77153% with 344 lines in your changes missing coverage. Please review.

Project coverage is 70.60%. Comparing base (afb9193) to head (5d5fee9). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...heduler/Notifications/SchedulerNotifications.swift 76.67% 123 Missing :warning:
Sources/SpeziSchedulerUI/TodayList.swift 0.00% 65 Missing :warning:
...heduler/Notifications/Schedule+Notifications.swift 62.50% 27 Missing :warning:
.../SpeziScheduler/Schedule/Duration+Extensions.swift 12.50% 21 Missing :warning:
Sources/SpeziSchedulerUI/DefaultTileHeader.swift 23.08% 20 Missing :warning:
...cations/BGTaskSchedulerErrorCode+Description.swift 0.00% 12 Missing :warning:
...tifications/NotificationScenePhaseScheduling.swift 42.86% 12 Missing :warning:
Sources/SpeziScheduler/Scheduler.swift 89.29% 12 Missing :warning:
Sources/SpeziScheduler/Schedule/Schedule.swift 89.33% 11 Missing :warning:
...SchedulerUI/Category/TaskCategoryAppearances.swift 54.17% 11 Missing :warning:
... and 9 more
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49/graphs/tree.svg?width=650&height=150&src=pr&token=0VQNE0E1Wp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi)](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) ```diff @@ Coverage Diff @@ ## main #49 +/- ## ========================================== + Coverage 63.11% 70.60% +7.50% ========================================== Files 24 40 +16 Lines 1648 2697 +1049 ========================================== + Hits 1040 1904 +864 - Misses 608 793 +185 ``` | [Files with missing lines](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) | Coverage Δ | | |---|---|---| | [Sources/SpeziScheduler/EventQuery.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?src=pr&el=tree&filepath=Sources%2FSpeziScheduler%2FEventQuery.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aVNjaGVkdWxlci9FdmVudFF1ZXJ5LnN3aWZ0) | `96.11% <ø> (-0.32%)` | :arrow_down: | | [.../SpeziScheduler/Notifications/BackgroundMode.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?src=pr&el=tree&filepath=Sources%2FSpeziScheduler%2FNotifications%2FBackgroundMode.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aVNjaGVkdWxlci9Ob3RpZmljYXRpb25zL0JhY2tncm91bmRNb2RlLnN3aWZ0) | `100.00% <100.00%> (ø)` | | | [...peziScheduler/Notifications/NotificationTime.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?src=pr&el=tree&filepath=Sources%2FSpeziScheduler%2FNotifications%2FNotificationTime.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aVNjaGVkdWxlci9Ob3RpZmljYXRpb25zL05vdGlmaWNhdGlvblRpbWUuc3dpZnQ=) | `100.00% <100.00%> (ø)` | | | [...ifications/PermittedBackgroundTaskIdentifier.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?src=pr&el=tree&filepath=Sources%2FSpeziScheduler%2FNotifications%2FPermittedBackgroundTaskIdentifier.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aVNjaGVkdWxlci9Ob3RpZmljYXRpb25zL1Blcm1pdHRlZEJhY2tncm91bmRUYXNrSWRlbnRpZmllci5zd2lmdA==) | `100.00% <100.00%> (ø)` | | | [...es/SpeziScheduler/Schedule/Schedule+Duration.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?src=pr&el=tree&filepath=Sources%2FSpeziScheduler%2FSchedule%2FSchedule%2BDuration.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aVNjaGVkdWxlci9TY2hlZHVsZS9TY2hlZHVsZStEdXJhdGlvbi5zd2lmdA==) | `56.93% <100.00%> (+4.62%)` | :arrow_up: | | [Sources/SpeziScheduler/Task/Task+Category.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?src=pr&el=tree&filepath=Sources%2FSpeziScheduler%2FTask%2FTask%2BCategory.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aVNjaGVkdWxlci9UYXNrL1Rhc2srQ2F0ZWdvcnkuc3dpZnQ=) | `66.67% <ø> (+33.34%)` | :arrow_up: | | [Sources/SpeziScheduler/Utils/Measure.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?src=pr&el=tree&filepath=Sources%2FSpeziScheduler%2FUtils%2FMeasure.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aVNjaGVkdWxlci9VdGlscy9NZWFzdXJlLnN3aWZ0) | `100.00% <100.00%> (ø)` | | | [...ry/DisableCategoryDefaultAppearancesModifier.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?src=pr&el=tree&filepath=Sources%2FSpeziSchedulerUI%2FCategory%2FDisableCategoryDefaultAppearancesModifier.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aVNjaGVkdWxlclVJL0NhdGVnb3J5L0Rpc2FibGVDYXRlZ29yeURlZmF1bHRBcHBlYXJhbmNlc01vZGlmaWVyLnN3aWZ0) | `100.00% <100.00%> (ø)` | | | [...hedulerUI/TestingSupport/SchedulerSampleData.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?src=pr&el=tree&filepath=Sources%2FSpeziSchedulerUI%2FTestingSupport%2FSchedulerSampleData.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aVNjaGVkdWxlclVJL1Rlc3RpbmdTdXBwb3J0L1NjaGVkdWxlclNhbXBsZURhdGEuc3dpZnQ=) | `68.75% <100.00%> (+1.36%)` | :arrow_up: | | [...eduler/Notifications/TaskNextOccurrenceCache.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?src=pr&el=tree&filepath=Sources%2FSpeziScheduler%2FNotifications%2FTaskNextOccurrenceCache.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aVNjaGVkdWxlci9Ob3RpZmljYXRpb25zL1Rhc2tOZXh0T2NjdXJyZW5jZUNhY2hlLnN3aWZ0) | `92.31% <92.31%> (ø)` | | | ... and [18 more](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) | | ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). Last update [afb9193...5d5fee9](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/49?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi).