Skip to content

Commit

Permalink
feat(fcm): Enabled direct_boot_ok Android Config parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanedey committed Nov 15, 2023
1 parent c77608e commit 6651302
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions firebase_admin/_messaging_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ def check_analytics_label(cls, label, value):
raise ValueError('Malformed {}.'.format(label))
return value

@classmethod
def check_boolean(cls, label, value):
"""Checks if the given value is boolean."""
if value is None:
return None
if not isinstance(value, bool):
raise ValueError('{0} must be a boolean.'.format(label))
return value

@classmethod
def check_datetime(cls, label, value):
"""Checks if the given value is a datetime."""
Expand Down Expand Up @@ -214,6 +223,8 @@ def encode_android_fcm_options(cls, fcm_options):
result = {
'analytics_label': _Validators.check_analytics_label(
'AndroidFCMOptions.analytics_label', fcm_options.analytics_label),
'direct_boot_ok': _Validators.check_boolean(
'AndroidFCMOptions.direct_boot_ok', fcm_options.direct_boot_ok)
}
result = cls.remove_null_values(result)
return result
Expand Down
5 changes: 4 additions & 1 deletion firebase_admin/_messaging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,13 @@ class AndroidFCMOptions:
Args:
analytics_label: contains additional options for features provided by the FCM Android SDK
(optional).
direct_boot_ok: A boolean indicating whether messages will be allowed to be delivered to
the app while the device is in direct boot mode.
"""

def __init__(self, analytics_label=None):
def __init__(self, analytics_label=None, direct_boot_ok=None):
self.analytics_label = analytics_label
self.direct_boot_ok = direct_boot_ok


class WebpushConfig:
Expand Down

0 comments on commit 6651302

Please sign in to comment.