Skip to content

Commit 6651302

Browse files
committed
feat(fcm): Enabled direct_boot_ok Android Config parameter.
1 parent c77608e commit 6651302

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

firebase_admin/_messaging_encoder.py

+11
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ def check_analytics_label(cls, label, value):
160160
raise ValueError('Malformed {}.'.format(label))
161161
return value
162162

163+
@classmethod
164+
def check_boolean(cls, label, value):
165+
"""Checks if the given value is boolean."""
166+
if value is None:
167+
return None
168+
if not isinstance(value, bool):
169+
raise ValueError('{0} must be a boolean.'.format(label))
170+
return value
171+
163172
@classmethod
164173
def check_datetime(cls, label, value):
165174
"""Checks if the given value is a datetime."""
@@ -214,6 +223,8 @@ def encode_android_fcm_options(cls, fcm_options):
214223
result = {
215224
'analytics_label': _Validators.check_analytics_label(
216225
'AndroidFCMOptions.analytics_label', fcm_options.analytics_label),
226+
'direct_boot_ok': _Validators.check_boolean(
227+
'AndroidFCMOptions.direct_boot_ok', fcm_options.direct_boot_ok)
217228
}
218229
result = cls.remove_null_values(result)
219230
return result

firebase_admin/_messaging_utils.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,13 @@ class AndroidFCMOptions:
203203
Args:
204204
analytics_label: contains additional options for features provided by the FCM Android SDK
205205
(optional).
206+
direct_boot_ok: A boolean indicating whether messages will be allowed to be delivered to
207+
the app while the device is in direct boot mode.
206208
"""
207209

208-
def __init__(self, analytics_label=None):
210+
def __init__(self, analytics_label=None, direct_boot_ok=None):
209211
self.analytics_label = analytics_label
212+
self.direct_boot_ok = direct_boot_ok
210213

211214

212215
class WebpushConfig:

0 commit comments

Comments
 (0)