Skip to content

Push Notifications

IssaIan edited this page Sep 1, 2019 · 1 revision

While the Backend API, Companion App and the Mobile App can each independently make calls to the Google Calendar API, none of them can on their own receive updates on changes made to the Calendars that they listen to. This is the reason for the birth of the push notifications micro service. The push notifications service enables the Google Calendar API to push notifications whenever there are changes to any registered calendars.

How the push notifications work on Converge.

The Backend app (mrm_api) allows us to create and save rooms in a database. Upon creation of a room, the rooms calendar_id and firebase_token are sent to the Push Notifications micro service app (mrm_push) via a celery task. This task hits the add_room endpoint in the mrm_push. This in turn allows for the creation of a channel. This channel is used by the Google Calendar API to send notifications for the registered calendar_id upon changes to any events on the aforementioned calendar.

Upon deletion of a room on the mrm_api, the rooms **calendar_id ** is sent via a celery task to the mrm_push app. This task hits the delete_room endpoint which stops the channel with the specified calendar_id from continuing to receive notifications from the Google Calendar API.

The firebase tokens of various rooms expires after a given period. This is why there exists the refresh endpoint. This endpoint queries all rooms from the mrm_api database and returns the calendar_id and firebase token for each and every room. This allows the mrm_push to be updated with the active rooms’ calendar ids and firebase tokens which in turn allow their channels to also be updated.

The mrm_push currently uses a Redis database. However, we are in the process of transitioning to a SQLAlchemy database. The Google Calendar API hits the notifications endpoint when sending any notifications. This notifications are in turn saved in the database. At the moment, notifications are sent to the Android devices attached to every room.

Clone this wiki locally