SwEnt-Group13 / Unio

The world’s largest campus life platform.
3 stars 1 forks source link

Feature: event notifications #200

Closed armouldr closed 2 days ago

armouldr commented 1 week ago

We want to incorporate notifications to our app. As a start, this PR aims to send a notification to the user when one of their saved events is starting in a few (2) hours. We established that this kind of reminder notification needed to work offline, so I decided to not use a Firebase solution for this. Instead, I used android's AlarmManager that allows to schedule an Intent, even when the app is closed or when the phone is in standby mode. What I added: -NotificationWorker: An interface between UI and the NotificationScheduler. The called method(schedule/unscheduled) enqueues a task so that it can be done asynchronously. Then doWork method calls the appropriate function in NotificationScheduler.

-NotificationScheduler: Schedules/Unschedules notifications using AlarmManager. It's onReceive method is called when the AlarmManager's time is up and triggers the notification.

-Notification.kt : A useful dataclass for representing a notification :) will probably be useful with other types of notifications later on -In AndroidManifest : added an intent receiver that checks for action BOOT_COMPLETED, in order to reschedule the notification if the phone was shutdown :sunglasses:

sonarcloud[bot] commented 3 days ago

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
75.9% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud