[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:

  1. Mobile app sends device token to the server.

  2. Server stores devices_token in to DB. One user can have several device_tokens.

  3. On the specific events a PN should be sent for specific user for each their device_token.

  4. User receives the PN on their device.

PN functionality is planned to be implemented in edx-platform and edx-ace repositories.

  1. 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.

  2. edx-ace is planned to be extended by:

    1. Extending Recipient to have additional device_token field.

    2. Add PushNotificationChannel, similar to other channels in the edx-ace

    3. Add PushNotificationRenderer, similar to EmailRenderer but for PN.

    4. Use django-push-notifications OR firebase-admin-python.

      1. django-push-notifications

        1. contains all required modules like models, views, serializers and urls for adding device_token into the system

        2. initialization using credentials from FCM

        3. the plan is to incapsulate functionality from the package into the edx-ace (reexport)

      2. firebase-admin-python (in case django-push-notifications won’t work for us)

        1. requires to implement initialization, models, serializer, url and additional functionality that is implemented by django-push-notifications

  3. Integration of incapsulated Push Notifications functionality from the edx-ace into edx-platform

    1. Extend INSTALLED_APPS with django-push-notifications that is planned to be defined in the edx-ace

    2. Extend urls for POST device_token endpoint

    3. Use similar way to send PN as already done for Emails from edx-ace

Problems & Open Questions

  1. 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.

    1. 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) Add aioapns version of APNS by pomali · Pull Request #696 · jazzband/django-push-notifications, so we believe this issue could be solved really soon. And there’re no big risks for using django-push-notifications.

  2. Where the push notifications app should be initialized? Example: we specify FCM_API_KEY and initialization should be in the edx-ace or in the edx-platform.

    1. Solution: Approach the same way as Emails configuration, use Django settings in ace_common edx-platform/openedx/core/djangoapps/ace_common/settings/common.py at ddb407a3f2c75bb65746a4c16ba32b2c26296019 · openedx/edx-platform 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.

  3. In case we use django-push-notifications, what is the best way to extend INSTALLED_APPS? Install it straight into edx-platform or only edx-ace?

    1. Patch Installed_apps in a plugin settings, if Push Notifications are activated - edx-platform/openedx/core/djangoapps/ace_common/settings/common.py at ddb407a3f2c75bb65746a4c16ba32b2c26296019 · openedx/edx-platform

  4. If we don’t use django-push-notifications can we create models and endpoint in the edx-ace

    1. 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):

  1. We start implementing the solution with edx-ace right now.

  2. edx-ace Push Notifications will be imported and used under lms/djangoapps/mobile_api

  3. Do we want to implement user preferences? In the notifications app in edx-platform there is preferences system.

User Notifications Preferences

  1. How user should manage preferences for receiving notifications?

  2. Can we extend the Notifications django app in openedx/core - edx-platform/openedx/core/djangoapps/notifications at master · openedx/edx-platform?

  3. Would it be possible to follow ACE architecture - edx-ace/docs/design.rst at master · openedx/edx-ace?