-
-
Notifications
You must be signed in to change notification settings - Fork 620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add FCM v1 API #702
Add FCM v1 API #702
Conversation
for more information, see https://pre-commit.ci
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #702 +/- ##
==========================================
+ Coverage 69.51% 70.28% +0.76%
==========================================
Files 26 26
Lines 1122 1097 -25
Branches 245 249 +4
==========================================
- Hits 780 771 -9
+ Misses 304 288 -16
Partials 38 38 ☔ View full report in Codecov by Sentry. |
will reopen after i've fixed tests |
@jamaalscarlett @jleclanche Any sense of when this might be reviewed? Would be really great to have FCM v1 support merged in soon with the legacy API going away in 2024/06/20 |
@ceoy nice work. In your changes to the docs, you have: firebase_app = firebase_admin.initialize_app()
PUSH_NOTIFICATIONS_SETTINGS = {
# Load and process all PUSH_NOTIFICATIONS_SETTINGS using the AppConfig manager.
"CONFIG": "push_notifications.conf.AppConfig",
# collection of all defined applications
"APPLICATIONS": {
"my_fcm_app": {
# PLATFORM (required) determines what additional settings are required.
"PLATFORM": "FCM",
# FCM settings
"FIREBASE_APP": firebase_app,
},
"my_ios_app": {
# PLATFORM (required) determines what additional settings are required.
"PLATFORM": "APNS",
# required APNS setting
"CERTIFICATE": "/path/to/your/certificate.pem",
},
"my_wns_app": {
# PLATFORM (required) determines what additional settings are required.
"PLATFORM": "WNS",
# required WNS settings
"PACKAGE_SECURITY_ID": "[your package security id, e.g: 'ms-app://e-3-4-6234...']",
"SECRET_KEY": "[your app secret key, e.g.: 'KDiejnLKDUWodsjmewuSZkk']",
},
} Would this allow for setting up and initializing multiple firebase_admin apps, each with different service account credentials and then being to dynamically choose which app to send the push with at the time of sending the message? Or would this work some other way? I'm trying to get a sense for how we can use multiple Firebase apps with this. |
Yes, exactly. This part is basically the same as before (old documentation here https://github.com/jazzband/django-push-notifications), you just need to set the The config is then selected depending on the value of the |
Excellent, thanks @ceoy |
very nice job!! @ceoy |
@ceoy any idea why the python 3.6 test is failing? |
not sure, i have some time tomorrow to check 👀 |
@jamaalscarlett fixed now, bit of a weird issue and there is probably a better way to fix it 😆 |
Thanks @ceoy for this PR. Very nice work. |
@ceoy, good work out here! thanks for sending in this patch, re-running the pipeline all test now passes with the new update 👍🏼 cc: @jamaalscarlett |
@@ -1,7 +1,9 @@ | |||
from django.db import models | |||
from django.utils.translation import gettext_lazy as _ | |||
from firebase_admin import messaging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import should be placed in the gcm
package, since if placed here it turns firebase_admin
as a mandatory requirements for everyone.
* Add FCM v1 API * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add Unit Tests for GCMDeviceAdmin and fix FCM v1 tests * fixes admin test for python 3.6 --------- Co-authored-by: Tim Jahn <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add FCM v1 API * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add Unit Tests for GCMDeviceAdmin and fix FCM v1 tests * fixes admin test for python 3.6 --------- Co-authored-by: Tim Jahn <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Use new FCM v1 API by using firebase_admin SDK.
Resolves #546