Skip to content

Commit df85e6c

Browse files
Support push for Live Activity (#668)
* Support push for Live Activity * Limit Live Activity support to LiveActivityToken field only As per review feedback, removed all extra Live Activity fields from Aps struct: - Removed StaleDate, ContentState, Timestamp, Event, DismissalDate, AttributesType, and Attributes fields - Removed LiveActivityEvent type and constants - Updated tests to only test LiveActivityToken field - Kept only the essential LiveActivityToken field in APNSConfig as requested --------- Co-authored-by: Jonathan Edey <[email protected]>
1 parent 8775cc8 commit df85e6c

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

messaging/messaging.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,10 @@ type WebpushFCMOptions struct {
664664
// See https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html
665665
// for more details on supported headers and payload keys.
666666
type APNSConfig struct {
667-
Headers map[string]string `json:"headers,omitempty"`
668-
Payload *APNSPayload `json:"payload,omitempty"`
669-
FCMOptions *APNSFCMOptions `json:"fcm_options,omitempty"`
667+
Headers map[string]string `json:"headers,omitempty"`
668+
Payload *APNSPayload `json:"payload,omitempty"`
669+
FCMOptions *APNSFCMOptions `json:"fcm_options,omitempty"`
670+
LiveActivityToken string `json:"live_activity_token,omitempty"`
670671
}
671672

672673
// APNSPayload is the payload that can be included in an APNS message.

messaging/messaging_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,21 @@ var validMessages = []struct {
588588
"topic": "test-topic",
589589
},
590590
},
591+
{
592+
name: "APNSLiveActivity",
593+
req: &Message{
594+
Token: "test-token",
595+
APNS: &APNSConfig{
596+
LiveActivityToken: "live-activity-token",
597+
},
598+
},
599+
want: map[string]interface{}{
600+
"token": "test-token",
601+
"apns": map[string]interface{}{
602+
"live_activity_token": "live-activity-token",
603+
},
604+
},
605+
},
591606
{
592607
name: "AndroidNotificationPriorityMin",
593608
req: &Message{

0 commit comments

Comments
 (0)