[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_tokenin to DB. One user can have severaldevice_tokens.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-platformwill 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-aceis planned to be extended by:Extending Recipient to have additional
device_tokenfield.Add
PushNotificationChannel, similar to other channels in theedx-aceAdd
PushNotificationRenderer, similar toEmailRendererbut 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_tokeninto 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-aceintoedx-platformExtend
INSTALLED_APPSwithdjango-push-notificationsthat is planned to be defined in theedx-aceExtend urls for POST
device_tokenendpointUse 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_KEYand initialization should be in theedx-aceor 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-platformor 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-aceWe will use it, also some specific models and Views can be exposed via
mobile_api applicationin LMS
New questions & updates (2024.04.09):
We start implementing the solution with
edx-aceright now.edx-acePush Notifications will be imported and used underlms/djangoapps/mobile_apiDo we want to implement user preferences? In the notifications app in
edx-platformthere 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?