diff --git a/CHANGELOG.md b/CHANGELOG.md index 5df234d..fa2a1b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # Changelog +## [0.4.0](https://github.com/sdb9696/firebase-messaging/tree/0.4.0) (2024-08-29) + +[Full Changelog](https://github.com/sdb9696/firebase-messaging/compare/0.3.0...0.4.0) + +**Release highlights:** + +- Support for new FCM HTTP v1 API +- Previous versions of this library will no longer work due firebase [deprecating the legacy APIs](https://firebase.google.com/docs/cloud-messaging/migrate-v1) +- Dropping official python 3.8 support +- **Breaking** - this version of the library only supports being run in an asyncio event loop +- **Breaking** - The api has changed, see the readme for updated details + +**Breaking change pull requests:** + +- Drop python 3.8 support and update CI [\#5](https://github.com/sdb9696/firebase-messaging/pull/5) (@sdb9696) + +**Implemented enhancements:** + +- Support FCM HTTP v1 \(async only\) [\#4](https://github.com/sdb9696/firebase-messaging/pull/4) (@sdb9696) + +**Project maintenance:** + +- Update releasing instructions and add changelog [\#6](https://github.com/sdb9696/firebase-messaging/pull/6) (@sdb9696) + ## [0.3.0](https://github.com/sdb9696/firebase-messaging/tree/0.3.0) (2024-03-26) [Full Changelog](https://github.com/sdb9696/firebase-messaging/compare/0.2.1...0.3.0) @@ -79,5 +103,4 @@ - Fix publish workflow ([447d379](https://github.com/sdb9696/firebase-messaging/commit/447d37922aa2589e79b3952036ef10b02debb01a) by sdb9696). - \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/README.rst b/README.rst index a97172c..a2dbf80 100644 --- a/README.rst +++ b/README.rst @@ -46,26 +46,34 @@ PyPi:: Requirements ------------ -- Firebase sender id to receive notification -- Firebase serverKey to send notification (optional) +- Firebase configuration to receive notifications Usage ----- +Must be run inside an asyncio event loop. + python:: - from firebase_messaging import FcmPushClient + from firebase_messaging import FcmPushClient, FcmRegisterConfig def on_notification(obj, notification, data_message): # Do something with the notification pass - pc = FcmPushClient(None) - fcm_token = pc.checkin(sender_id, app_id) + credentials = None # Start off with none or load from previous save + def on_credentials_updated(creds): + # save the credentials to a file here for future use + + fcm_config = FcmRegisterConfig(fcm-project-id, fcm-app-id, fcm-api-key, fcm-message-sender-id) + pc = FcmPushClient(on_notification, fcm_config, credentials, on_credentials_updated) + fcm_token = await pc.checkin_or_register() - # Notify the service you're connecting to of your FCM token + await pc.start() - pc.start(YOUR_NOTIFICATION_CALLBACK) + # Adapt the following for your usage + while some_condition_to_keep_listening: + asyncio.sleep(2) Attribution diff --git a/RELEASING.md b/RELEASING.md index 23c0a10..1454e25 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -23,8 +23,8 @@ export NEW_RELEASE=x.x.x ```bash git checkout main -git fetch upstream main -git rebase upstream/main +git fetch origin main +git rebase origin/main git checkout -b release/$NEW_RELEASE ``` @@ -111,7 +111,7 @@ echo "$RELEASE_NOTES" # Check the output and copy paste if neccessary ```bash git commit --all --verbose -m "Prepare $NEW_RELEASE" -git push upstream release/$NEW_RELEASE -u +git push origin release/$NEW_RELEASE -u ``` ### Create a PR for the release, merge it, and re-fetch the main @@ -133,8 +133,8 @@ gh pr merge --squash --body "$RELEASE_NOTES" ```bash git checkout main -git fetch upstream main -git rebase upstream/main +git fetch origin main +git rebase origin/main ``` ### Create a release tag @@ -143,7 +143,7 @@ Note, add changelog release notes as the tag commit message so `gh release creat ```bash git tag --annotate $NEW_RELEASE -m "$RELEASE_NOTES" # to create a signed tag replace --annotate with --sign -git push upstream $NEW_RELEASE +git push origin $NEW_RELEASE ``` ### Create release diff --git a/pyproject.toml b/pyproject.toml index f1d2d84..3c45582 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "firebase-messaging" -version = "0.3.0" +version = "0.4.0" description = "FCM/GCM push notification client" authors = ["sdb9696 "] license = "MIT"