Notifications
-Written by: Quincy Williams
This week, my focus was on notifications. I ran into some issues with getting the notifications to work as there are many different ways to achieve how notifications are displayed to the user and when. The main goal was to be able to have the user control the ability of when the notification is seen or not, based on a setting in the settings activity. This was accessed by shared preferences to be able to detect if the options was set to determine if the notification should fire, via a boolean value.
The more difficult issue as figuring out the best way to have the application alert the user with a notification. There were a lot of options but the best option seemed to be using an AlarmManager and receiver to have the notification trigger at a specific time of the day. This required creating three separate classes to house each activity.
The notification needed to be built to allow for the user to be able to click on the notification and open the app, so channel IDs, notification channels and pending intents needed to be created in order to have the notification open the application.
The receiver portion of the notification would have the AlarmManager object sent to it and then the receiver would create the notification, seen above, once it has received an event from the AlarmManger object. The object would be created on app startup.
Comments
Post a Comment