The main purpose of this PR is the introduction of push notification management. Testing is... tricky. I don't have a LAN that allows for testing local client with local backend. I tested against the deployed version at https://bahk-staging-b03c4b296be6.herokuapp.com. Expected behavior is that when the client logs in, if its on a device (iOS/android), a push token is registered on the backend. The token can be used for sending push messages to the client. A manual testing function is included in this PR, via API request or the backend admin, but the admin interface is not working yet. The API request test can be performed from:
curl -X POST http://URL/api/notifications/test-push/ \
-H "Content-Type: application/json" \
-d '{
"token": "ExponentPushToken[XXXXXX. X]",
"message": "Hello! This is a test notification"
}'
No logic is provided in this PR to send programmatic notifications to users about fasts. That will come in a separate PR.
Note: testing this also requires defining the APNS_CERTIFICATE_FILENAME in environment variables. The value can be sent to you via email, as it should be kept a secret.
This pull request includes significant updates to the bahk and hub applications, as well as the introduction of a new notifications app to handle push notifications. The most important changes include configuring AWS S3 settings, enhancing the database seeding process, and adding functionalities for managing and sending push notifications.
Configuration and Settings Updates:
bahk/settings.py: Integrated AWS S3 settings for certificates and added configurations for push notifications. Updated the DEBUG and ALLOWED_HOSTS settings to use environment variables. [1][2]
Database Seeding Enhancements:
hub/management/commands/seed.py: Improved the seeding command by adding transaction management, resetting sequences, and refactoring the data population logic. [1][2]
Push Notifications Implementation:
notifications/admin.py: Added an admin interface for managing device tokens and sending push notifications.
notifications/models.py: Created the DeviceToken model to store device tokens for push notifications.
notifications/urls.py: Defined URLs for registering device tokens and testing push notifications.
These changes enhance the project's configuration management, streamline the database seeding process, and introduce a robust system for handling push notifications.This pull request introduces a new push notifications feature to the project. It includes changes to settings, URLs, models, serializers, views, and utility functions to support the new functionality.
Settings and Configuration:
Added notifications and push_notifications to the installed apps in bahk/settings.py.
Configured push notification settings and implemented logic to download the APNS certificate from a URL in bahk/settings.py.
URL Routing:
Added a route for push notifications endpoints in hub/urls.py.
Notifications App:
Created DeviceToken model and registered it in the admin interface in notifications/admin.py and notifications/models.py. [1][2]
Generated initial migration for the DeviceToken model in notifications/migrations/0001_initial.py.
Created a serializer for the DeviceToken model in notifications/serializers.py.
Added a view to handle device token registration in notifications/views.py.
Defined a URL pattern for device token registration in notifications/urls.py.
Implemented a utility function to send push notifications using the Expo SDK in notifications/utils.py.
Testing:
Created a placeholder for tests in notifications/tests.py.
The main purpose of this PR is the introduction of push notification management. Testing is... tricky. I don't have a LAN that allows for testing local client with local backend. I tested against the deployed version at https://bahk-staging-b03c4b296be6.herokuapp.com. Expected behavior is that when the client logs in, if its on a device (iOS/android), a push token is registered on the backend. The token can be used for sending push messages to the client. A manual testing function is included in this PR, via API request or the backend admin, but the admin interface is not working yet. The API request test can be performed from:
curl -X POST http://URL/api/notifications/test-push/ \ -H "Content-Type: application/json" \ -d '{ "token": "ExponentPushToken[XXXXXX. X]", "message": "Hello! This is a test notification" }'
No logic is provided in this PR to send programmatic notifications to users about fasts. That will come in a separate PR.
Note: testing this also requires defining the APNS_CERTIFICATE_FILENAME in environment variables. The value can be sent to you via email, as it should be kept a secret.
This pull request includes significant updates to the
bahk
andhub
applications, as well as the introduction of a newnotifications
app to handle push notifications. The most important changes include configuring AWS S3 settings, enhancing the database seeding process, and adding functionalities for managing and sending push notifications.Configuration and Settings Updates:
bahk/settings.py
: Integrated AWS S3 settings for certificates and added configurations for push notifications. Updated theDEBUG
andALLOWED_HOSTS
settings to use environment variables. [1] [2]Database Seeding Enhancements:
hub/management/commands/seed.py
: Improved the seeding command by adding transaction management, resetting sequences, and refactoring the data population logic. [1] [2]Push Notifications Implementation:
notifications/admin.py
: Added an admin interface for managing device tokens and sending push notifications.notifications/models.py
: Created theDeviceToken
model to store device tokens for push notifications.notifications/serializers.py
: Added a serializer for theDeviceToken
model.notifications/urls.py
: Defined URLs for registering device tokens and testing push notifications.These changes enhance the project's configuration management, streamline the database seeding process, and introduce a robust system for handling push notifications.This pull request introduces a new push notifications feature to the project. It includes changes to settings, URLs, models, serializers, views, and utility functions to support the new functionality.
Settings and Configuration:
notifications
andpush_notifications
to the installed apps inbahk/settings.py
.bahk/settings.py
.URL Routing:
hub/urls.py
.Notifications App:
DeviceToken
model and registered it in the admin interface innotifications/admin.py
andnotifications/models.py
. [1] [2]DeviceToken
model innotifications/migrations/0001_initial.py
.DeviceToken
model innotifications/serializers.py
.notifications/views.py
.notifications/urls.py
.notifications/utils.py
.Testing:
notifications/tests.py
.