AsyncFirebaseClient
empower with advanced features to configure request behaviour such as timeout, or connection pooling. Example:
from async_firebase.client import AsyncFirebaseClient, RequestTimeout
# This will disable timeout
client = AsyncFirebaseClient(..., request_timeout=RequestTimeout(None))
client.send(...)
- [FIX] The push notification could not be sent to topic because
messages.Message.token
is declared as required attribute though it should be optional.messages.Message.token
turned into Optional attribute.
- The limit on the number of messages (>= 500) that can be sent using the
send_all
method has been restored.
Remastering client interface
- [BREAKING] The methods
push
andpush_multicast
renamed tosend
andsend_multicast
accordingly. - [BREAKING] The signatures of the methods
send
andsend_multicast
have been changed.- Method
send
accepts instance ofmessages.Message
and returnsmessages.FCMBatchResponse
- Method
send_multicast
accepts instance ofmessages.MulticastMessage
and returnsmessages.FCMBatchResponse
- Method
- New method
send_all
to send messages in a single batch has been added. It takes a list ofmessages.Message
instances and returnsmessages.FCMBatchResponse
. README.md
has been updated to highlight different in interfaces for versions prior 3.x and after- Improved naming:
messages.FcmPushMulticastResponse
tomessages.FCMBatchResponse
messages.FcmPushResponse
tomessages.FCMResponse
utils.FcmReponseType
toutils.FCMResponseType
utils.FcmResponseHandler
toutils.FCMResponseHandlerBase
utils.FcmPushResponseHandler
toutils.FCMResponseHandler
utils.FcmPushMulticastResponseHandler
toutils.FCMBatchResponseHandler
- Type annotations and doc string were updated according to new naming.
- Class
AsyncFirebaseClient
has been refactored. Communication related code extracted into base class.
async_firebase.encoders.aps_encoder
no longer clearscustom_data
dictionary, as this causes subsequent notifications to not get any content incustom_data
dictionary.
- Add object for sending Web Push.
- Fix WebPush type annotation
- Adds field
notification_count
toAndroidNotification
message.
- [BREAKING] Drop support of Python 3.6
- Update dependencies
- Make implicit optional type hints PEP 484 compliant.
Method client.build_android_config
has been adjusted, so when data
parameter is passed but the value is not set (equal to None
),
turn in into "null"
async_firebase now works with Python 3.11
- Removes
asynctest
as it is no longer maintained ref
messages.Notification
object now supports attributeimage
that allows to set image url of the notification
A few new error types have been added to support the errors that FCM API may return:
- InvalidArgumentError
- FailedPreconditionError
- OutOfRangeError
- UnauthenticatedError
- PermissionDeniedError
- NotFoundError
- AbortedError
- AlreadyExistsError
- ConflictError
- ResourceExhaustedError
- CancelledError
- DataLossError
- UnknownError
- InternalError
- UnavailableError
- DeadlineExceededError
- Adjust type annotations for some errors:
async_firebase/errors.py
class AsyncFirebaseError(BaseAsyncFirebaseError):
"""A prototype for all AF Errors.
This error and its subtypes and the reason to rise them are consistent with Google's errors,
that may be found in `firebase-admin-python` in `firebase_admin.exceptions module`.
"""
def __init__(
self,
code: str,
message: str,
<<< cause: t.Optional[Exception] = None,
>>> cause: t.Union[httpx.HTTPStatusError, httpx.RequestError, None] = None,
http_response: t.Optional[httpx.Response] = None,
):
**async_firebase/messages.py**
class FcmPushResponse:
"""The response received from an individual batched request to the FCM API.
The interface of this object is compatible with SendResponse object of
the Google's firebase-admin-python package.
"""
def __init__(
self,
fcm_response: t.Optional[t.Dict[str, str]] = None,
<<< exception: t.Optional[Exception] = None
>>> exception: t.Optional[AsyncFirebaseError] = None
):
- Fix
TypeError
on createAsyncFirebaseError
subclass instance
push
method now returns aFcmPushResponse
object, that has a fully compatible interface with SendResponse object of the Google's firebase-admin-python package.push_multicast
method now returns aFcmPushMulticastResponse
object, that has a fully compatible interface with BatchResponse object of the Google's firebase-admin-python package.- The aforementioned methods may still rise exceptions when assembling the message for the request.
- A bunch of exceptions has been added.
- [FIX] Invalid batch requests fixed in
push_multicast
method. - [FIX] Data mutation issues that lead to unexpected behaviour fixed in
assemble_push_notification
method. - Message
messages.MulticastMessage
was deprecated as it's no longer used.
- Add support of MulticastMessage
- Clean up. Remove dependencies and code that is no longer used.
- Update dependencies:
- Removed backports.entry-points-selectable (1.1.1)
- Removed chardet (4.0.0)
- Removed requests (2.25.1)
- Removed urllib3 (1.26.7)
- Updated idna (2.10 -> 3.3)
- Updated pyparsing (3.0.6 -> 3.0.7)
- Updated attrs (21.2.0 -> 21.4.0)
- Updated charset-normalizer (2.0.9 -> 2.0.12)
- Updated filelock (3.4.0 -> 3.4.1)
- Updated click (8.0.3 -> 8.0.4)
- Updated freezegun (1.1.0 -> 1.2.0)
- Updated identify (2.4.0 -> 2.4.4)
- Updated regex (2021.11.10 -> 2022.3.2)
- Installed tomli (1.2.3)
- Updated typed-ast (1.4.3 -> 1.5.2)
- Updated typing-extensions (4.0.1 -> 4.1.1)
- Updated virtualenv (20.10.0 -> 20.13.3)
- Updated google-auth (2.1.0 -> 2.6.0)
- Updated mypy (0.910 -> 0.931)
- Make _get_access_token async
- Add support of Python 3.10
- Fix typos in README.md
- Update dependencies
- Added channel_id option to Android config (spec)
- [FIX] Adjust APS encoder in order to properly construct background push notification.
- [FIX] Set properly attribute
content-available
for APNS payload. The attribute indicates that push notification should be considered background.
- [FIX] Use numeric representation for boolean attributes
mutable-content
andcontent-available
.
- [FIX] Encode
Aps
message according to APNS specification - [FIX] Util
cleanup_firebase_message
to remove null values for dict object. - [CHORE] Update dependencies
- [FIX]
APNSPayload
message no longer support attributecustom_data
- [FIX] APNS custom data properly incorporate into the push notification payload. So instead of passing
custom_data
as-is into payload and by that introducing one more nested level, extract all the key fromcustom_data
and put them on the same level asaps
attribute.
- Added verbosity when making request to Firebase
- Added instrumentation to cleanup Firebase message before it can gets send. This is requirements that Firebase put on us, otherwise it fails with 400 error code, which basically says that payload is not well formed.
- Update 3rd-party dependencies:
google-auth = "~1.27.1"
httpx = "<1.0.0"
-
Remastering main client.
-
method
build_common_message
completely dropped in favor of concept of message structures (modulemessages
). -
the signature of method
push
has changed. From now on, it expects to receive instances ofmessages.*
for Android config and APNS config rather than raw data, which then has to be dynamically analyzed and mapped to the most appropriate message type. -
static methods
build_android_message
andbuild_apns_message
renamed tobuild_android_config
andbuild_apns_config
. -
static methods
build_android_config
andbuild_apns_config
returnmessages.AndroidConfig
andmessages.APNSConfig
respectively and aimed to simplify the process of creating configurations.
-
-
Introduce module
messages
the main aim is to simplify the process of constructing Push notification messages. The module houses the message structures that can be used to construct a push notification payload. -
Fix CD workflow. Make step
release
dependent oncreate-virtualenv
. -
Update
README.md
with more examples. -
Every request to Firebase tagged with
X-Request-Id
- Method
push()
no longer has parameteralert_text
. The parameternotification_body
should be used instead.
- Fix version
- Update README.md
- First release on PyPI.