Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions firebase_admin/_messaging_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ def encode_apns(cls, apns):
'APNSConfig.headers', apns.headers),
'payload': cls.encode_apns_payload(apns.payload),
'fcm_options': cls.encode_apns_fcm_options(apns.fcm_options),
'live_activity_token': _Validators.check_string(
'APNSConfig.live_activity_token', apns.live_activity_token),
}
return cls.remove_null_values(result)

Expand Down
4 changes: 3 additions & 1 deletion firebase_admin/_messaging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,17 @@ class APNSConfig:
payload: A ``messaging.APNSPayload`` to be included in the message (optional).
fcm_options: A ``messaging.APNSFCMOptions`` instance to be included in the message
(optional).
live_activity_token: A live activity token string (optional).

.. _APNS Documentation: https://developer.apple.com/library/content/documentation\
/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html
"""

def __init__(self, headers=None, payload=None, fcm_options=None):
def __init__(self, headers=None, payload=None, fcm_options=None, live_activity_token=None):
self.headers = headers
self.payload = payload
self.fcm_options = fcm_options
self.live_activity_token = live_activity_token


class APNSPayload:
Expand Down
4 changes: 3 additions & 1 deletion tests/test_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,8 @@ def test_apns_config(self):
topic='topic',
apns=messaging.APNSConfig(
headers={'h1': 'v1', 'h2': 'v2'},
fcm_options=messaging.APNSFCMOptions('analytics_label_v1')
fcm_options=messaging.APNSFCMOptions('analytics_label_v1'),
live_activity_token='test_token_string'
),
)
expected = {
Expand All @@ -1107,6 +1108,7 @@ def test_apns_config(self):
'fcm_options': {
'analytics_label': 'analytics_label_v1',
},
'live_activity_token': 'test_token_string',
},
}
check_encoding(msg, expected)
Expand Down