[FC-0047] - Push notifications proposal
Main part
Push notifications (PN) functionality based on the Firebase Cloud Service (FCM) is planned to be added. Flow which is needed to be implemented:
Mobile app sends device token to the server.
Server stores
devices_token
in to DB. One user can have severaldevice_token
s.On the specific events a PN should be sent for specific user for each their
device_token
.User receives the PN on their device.
PN functionality is planned to be implemented in edx-platform and edx-ace repositories.
edx-platform
will contain all required environmental variables that is needed to authenticate our platform with FCM to be able to send authenticated requests to FCM service to send push notifications.edx-ace
is planned to be extended by:Extending Recipient to have additional
device_token
field.Add
PushNotificationChannel
, similar to other channels in theedx-ace
Add
PushNotificationRenderer
, similar toEmailRenderer
but for PN.Use django-push-notifications OR firebase-admin-python.
django-push-notifications
contains all required modules like models, views, serializers and urls for adding
device_token
into the systeminitialization using credentials from FCM
the plan is to incapsulate functionality from the package into the
edx-ace
(reexport)
firebase-admin-python (in case django-push-notifications won’t work for us)
requires to implement initialization, models, serializer, url and additional functionality that is implemented by django-push-notifications
Integration of incapsulated Push Notifications functionality from the
edx-ace
intoedx-platform
Extend
INSTALLED_APPS
withdjango-push-notifications
that is planned to be defined in theedx-ace
Extend urls for POST
device_token
endpointUse similar way to send PN as already done for Emails from
edx-ace
Problems & Open Questions
django-push-notifications is not supported currently for Python 3.10 and Django 4? Do we want to contribute this package or to use Firebase admin SDK.
Findings: The current package isn’t fully compatible with python3.10 and higher versions of python because of the APNS dependency used, there’s an active work is in progress on the PR (last reply 04/08/2024) https://github.com/jazzband/django-push-notifications/pull/696, so we believe this issue could be solved really soon. And there’re no big risks for using django-push-notifications.
Where the push notifications app should be initialized? Example: we specify
FCM_API_KEY
and initialization should be in theedx-ace
or in theedx-platform
.Solution: Approach the same way as Emails configuration, use Django settings in ace_common https://github.com/openedx/edx-platform/blob/ddb407a3f2c75bb65746a4c16ba32b2c26296019/openedx/core/djangoapps/ace_common/settings/common.py edx-platform to init variables, and ENV Tokens approach to override it for production installations. Use those settings in edx-ace code to configure a firebase client.
In case we use django-push-notifications, what is the best way to extend
INSTALLED_APPS
? Install it straight intoedx-platform
or onlyedx-ace
?Patch Installed_apps in a plugin settings, if Push Notifications are activated - https://github.com/openedx/edx-platform/blob/ddb407a3f2c75bb65746a4c16ba32b2c26296019/openedx/core/djangoapps/ace_common/settings/common.py
If we don’t use django-push-notifications can we create models and endpoint in the
edx-ace
We will use it, also some specific models and Views can be exposed via
mobile_api application
in LMS
New questions & updates (2024.04.09):
We start implementing the solution with
edx-ace
right now.edx-ace
Push Notifications will be imported and used underlms/djangoapps/mobile_api
Do we want to implement user preferences? In the notifications app in
edx-platform
there is preferences system.
User Notifications Preferences
How user should manage preferences for receiving notifications?
Can we extend the Notifications django app in openedx/core - https://github.com/openedx/edx-platform/tree/master/openedx/core/djangoapps/notifications?
Would it be possible to follow ACE architecture - https://github.com/openedx/edx-ace/blob/master/docs/design.rst#architecture?