-
Notifications
You must be signed in to change notification settings - Fork 339
feat(fcm): Add 12 new Android Notification Parameters Support #363
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
Conversation
71e60bf
to
d39bc45
Compare
d39bc45
to
ad0bebe
Compare
@hiranya911 : |
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.
Looks mostly good. Just a few clarifications needed in the docs, plus a few readability improvements.
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.
Looks pretty solid. Just a few nits from me, and then I'll be at an LGTM.
tests/test_messaging.py
Outdated
@pytest.mark.parametrize('data', NON_STRING_ARGS + ['', 'topic', 'priority', 'foo']) | ||
def test_invalid_visibility(self, data): | ||
notification = messaging.AndroidNotification(visibility=data) | ||
@pytest.mark.parametrize('visibility', NON_STRING_ARGS + ['', 'topic', 'priority', 'foo']) |
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.
Remove topic and priority
tests/test_messaging.py
Outdated
@@ -32,6 +32,7 @@ | |||
NON_DICT_ARGS = ['', list(), tuple(), True, False, 1, 0, {1: 'foo'}, {'foo': 1}] | |||
NON_OBJECT_ARGS = [list(), tuple(), dict(), 'foo', 0, 1, True, False] | |||
NON_LIST_ARGS = ['', tuple(), dict(), True, False, 1, 0, [1], ['foo', 1]] | |||
NON_UNUM_ARGS = ['1.23s', list(), tuple(), dict(), -1.23] |
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.
Nit: NON_UINT_ARGS?
result = { | ||
'color': _Validators.check_string( | ||
'LightSettings.color', light_settings.color, non_empty=True), | ||
'light_on_duration': cls.encode_milliseconds( |
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.
I think this is fine. But let's just document it as a milliseconds API for simplicity.
firebase_admin/_messaging_encoder.py
Outdated
class _Validators(object): | ||
"""A collection of data validation utilities. | ||
|
||
Methods provided in this class raise ValueErrors if any validations fail. |
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.
Is this a literal Lahiru? If so, let's code-font it (with backticks probably).
firebase_admin/_messaging_encoder.py
Outdated
|
||
|
||
class MessageEncoder(json.JSONEncoder): | ||
"""A custom JSONEncoder implementation for serializing Message instances into JSON.""" |
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.
Should this be capped? I'm thinking not.
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.
Thank you! I think JSONEncoder
is correct here. I will code-font it. These were from one of our existing modules (not new code) they appear here as new because I had moved them to a new module file. It is good to fix the code-fonts though! :)
firebase_admin/_messaging_encoder.py
Outdated
|
||
@classmethod | ||
def encode_android_fcm_options(cls, fcm_options): | ||
"""Encodes an AndroidFCMOptions instance into a json.""" |
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.
Looks like a literal.
firebase_admin/_messaging_encoder.py
Outdated
|
||
@classmethod | ||
def encode_android_fcm_options(cls, fcm_options): | ||
"""Encodes an AndroidFCMOptions instance into a json.""" |
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.
Should this be either "a JSON object" or maybe just "JSON?" Unless json
is actually a literal.
firebase_admin/_messaging_encoder.py
Outdated
|
||
@classmethod | ||
def encode_ttl(cls, ttl): | ||
"""Encodes a AndroidConfig TTL duration into a string.""" |
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.
"an AndroidConfig
(if literal)
firebase_admin/_messaging_encoder.py
Outdated
|
||
@classmethod | ||
def encode_android_notification(cls, notification): | ||
"""Encodes an AndroidNotification instance into JSON.""" |
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.
Literal?
firebase_admin/_messaging_encoder.py
Outdated
|
||
@classmethod | ||
def encode_webpush_notification_actions(cls, actions): | ||
"""Encodes a list of WebpushNotificationActions into JSON.""" |
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.
Literal? If not, then "Web Push notification actions" could even work.
firebase_admin/_messaging_encoder.py
Outdated
|
||
@classmethod | ||
def encode_webpush_fcm_options(cls, options): | ||
"""Encodes a WebpushFCMOptions instance into JSON.""" |
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.
Literal?
firebase_admin/_messaging_encoder.py
Outdated
|
||
@classmethod | ||
def encode_apns(cls, apns): | ||
"""Encodes an APNSConfig instance into JSON.""" |
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.
Literal?
firebase_admin/_messaging_encoder.py
Outdated
|
||
@classmethod | ||
def encode_apns_fcm_options(cls, fcm_options): | ||
"""Encodes an APNSFCMOptions instance into JSON.""" |
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.
Literal?
firebase_admin/_messaging_encoder.py
Outdated
|
||
@classmethod | ||
def encode_notification(cls, notification): | ||
"""Encodes an Notification instance into JSON.""" |
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.
Suggest "a notification"
firebase_admin/_messaging_encoder.py
Outdated
|
||
@classmethod | ||
def encode_fcm_options(cls, fcm_options): | ||
"""Encodes an FCMOptions instance into JSON.""" |
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.
Literal?
firebase_admin/_messaging_encoder.py
Outdated
|
||
@classmethod | ||
def encode_aps_alert(cls, alert): | ||
"""Encodes an ApsAlert instance into JSON.""" |
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.
Literal?
firebase_admin/_messaging_utils.py
Outdated
reference, sets the time that the event in the notification occurred as a | ||
``datetime.datetime`` instance. Notifications in the panel are sorted by this time | ||
(optional). | ||
local_only: Set whether or not this notification is relevant only to the current device. |
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.
Suggest sticking with "Sets"
firebase_admin/_messaging_utils.py
Outdated
watch. This hint can be set to recommend this notification not be bridged (optional). | ||
See Wear OS guides: | ||
https://developer.android.com/training/wearables/notifications/bridger#existing-method-of-preventing-bridging | ||
priority: Set the relative priority for this notification. Low-priority notifications may be |
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.
Here too: "Sets"
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.
Thanks Lahiru!
A couple of global thoughts:
-- Where we refer to literals, those should be code-fonted, with double backticks if that's what works with our Python doc parsing.
-- Total nit, but for setters we may want to stick with "Sets" whenever we are talking about a single method or property.
I tried but may not have caught all these nits.
aabafe3
to
04a9d50
Compare
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.
LGTM 👍
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.
Thanks Lahiru!
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.
LGTM. Thanks!
Discussion
Testing
API Changes
Messaging
added new fields toAndroidNotification
class.LightSettings
classRELEASE NOTE: Added a series of new parameters to the
AndroidNotification
class that allow further customization of notifications that target Android devices.