Skip to content

Commit 21aaf0c

Browse files
committed
APNSConfig live_activity_token field
https://firebase.google.com/docs/cloud-messaging/ios/live-activity With this field and this configuration I am able to send LiveActivity start messages: ``` messaging.Message( apns=messaging.APNSConfig( live_activity_token=live_activity_token, payload=messaging.APNSPayload( aps=messaging.Aps( alert=messaging.ApsAlert( title="Live Activity Started", body="Your live activity has been started", ), custom_data = { "input-push-token": 1, "event": "start", "timestamp": int(time.time()), "content-state": { "myAttribute": False }, "attributes-type": "LiveActivityAttributes", "attributes": { "myAttribute": False }, } ), headers={ "apns-priority": "5", }, ), ), token=cloud_messaging_token, ) ```
1 parent bde3fb0 commit 21aaf0c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

firebase_admin/_messaging_encoder.py

+1
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ 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('APNSConfig.live_activity_token', apns.live_activity_token),
532533
}
533534
return cls.remove_null_values(result)
534535

firebase_admin/_messaging_utils.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,18 @@ class APNSConfig:
332332
Args:
333333
headers: A dictionary of headers (optional).
334334
payload: A ``messaging.APNSPayload`` to be included in the message (optional).
335+
live_activity_token: A push to start live activity token (optional).
335336
fcm_options: A ``messaging.APNSFCMOptions`` instance to be included in the message
336337
(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, live_activity_token=None, fcm_options=None):
343344
self.headers = headers
344345
self.payload = payload
346+
self.live_activity_token = live_activity_token
345347
self.fcm_options = fcm_options
346348

347349

0 commit comments

Comments
 (0)