Skip to content

Commit 7cf45bf

Browse files
authored
Merge branch 'master' into fcm-http2
2 parents 9b6e95e + e0599f9 commit 7cf45bf

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

firebase_admin/_messaging_encoder.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@ def encode_apns(cls, apns):
529529
'APNSConfig.headers', apns.headers),
530530
'payload': cls.encode_apns_payload(apns.payload),
531531
'fcm_options': cls.encode_apns_fcm_options(apns.fcm_options),
532+
'live_activity_token': _Validators.check_string(
533+
'APNSConfig.live_activity_token', apns.live_activity_token),
532534
}
533535
return cls.remove_null_values(result)
534536

firebase_admin/_messaging_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,17 @@ class APNSConfig:
334334
payload: A ``messaging.APNSPayload`` to be included in the message (optional).
335335
fcm_options: A ``messaging.APNSFCMOptions`` instance to be included in the message
336336
(optional).
337+
live_activity_token: A live activity token string (optional).
337338
338339
.. _APNS Documentation: https://developer.apple.com/library/content/documentation\
339340
/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html
340341
"""
341342

342-
def __init__(self, headers=None, payload=None, fcm_options=None):
343+
def __init__(self, headers=None, payload=None, fcm_options=None, live_activity_token=None):
343344
self.headers = headers
344345
self.payload = payload
345346
self.fcm_options = fcm_options
347+
self.live_activity_token = live_activity_token
346348

347349

348350
class APNSPayload:

firebase_admin/messaging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class BatchResponse:
398398

399399
def __init__(self, responses: List[SendResponse]) -> None:
400400
self._responses = responses
401-
self._success_count = len([resp for resp in responses if resp.success])
401+
self._success_count = sum(1 for resp in responses if resp.success)
402402

403403
@property
404404
def responses(self) -> List[SendResponse]:

tests/test_messaging.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,8 @@ def test_apns_config(self):
10971097
topic='topic',
10981098
apns=messaging.APNSConfig(
10991099
headers={'h1': 'v1', 'h2': 'v2'},
1100-
fcm_options=messaging.APNSFCMOptions('analytics_label_v1')
1100+
fcm_options=messaging.APNSFCMOptions('analytics_label_v1'),
1101+
live_activity_token='test_token_string'
11011102
),
11021103
)
11031104
expected = {
@@ -1110,6 +1111,7 @@ def test_apns_config(self):
11101111
'fcm_options': {
11111112
'analytics_label': 'analytics_label_v1',
11121113
},
1114+
'live_activity_token': 'test_token_string',
11131115
},
11141116
}
11151117
check_encoding(msg, expected)

0 commit comments

Comments
 (0)