Skip to content

Commit 620dce9

Browse files
authored
Merge branch 'main' into improvements/Remove-dismissalDate-from-APNSStartLiveActivityNotification
2 parents e9a6ad7 + a22a0fc commit 620dce9

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

SUPPORT.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ Please refer to the [Contributing](CONTRIBUTING.md) section for more information
55

66
| Version | Supported |
77
| ------- | ------------------ |
8+
| 6.x.x | :white_check_mark: |
89
| 5.x.x | :white_check_mark: |
9-
| 4.x.x | :white_check_mark: |
10+
| 4.x.x | |
1011
| 3.x.x ||
1112
| 2.x.x ||
1213
| 1.x.x ||

Sources/APNSCore/LiveActivity/APNSStartLiveActivityNotification.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public struct APNSStartLiveActivityNotification<Attributes: Encodable & Sendable
9191
/// - appID: Your app’s bundle ID/app ID. This will be suffixed with `.push-type.liveactivity`.
9292
/// - contentState: Updated content-state of live activity
9393
/// - timestamp: Timestamp when sending notification
94+
/// - staleDate: Timestamp when the notification is marked as stale
9495
/// - apnsID: A canonical UUID that identifies the notification.
9596
/// - attributes: The ActivityAttributes of the live activity to start
9697
/// - attributesType: The type name of the ActivityAttributes you want to send
@@ -101,6 +102,7 @@ public struct APNSStartLiveActivityNotification<Attributes: Encodable & Sendable
101102
appID: String,
102103
contentState: ContentState,
103104
timestamp: Int,
105+
staleDate: Int? = nil,
104106
apnsID: UUID? = nil,
105107
attributes: Attributes,
106108
attributesType: String,
@@ -109,6 +111,7 @@ public struct APNSStartLiveActivityNotification<Attributes: Encodable & Sendable
109111
self.aps = APNSStartLiveActivityNotificationAPSStorage(
110112
timestamp: timestamp,
111113
contentState: contentState,
114+
staleDate: staleDate,
112115
alert: alert,
113116
attributes: attributes,
114117
attributesType: attributesType

Sources/APNSCore/LiveActivity/APNSStartLiveActivityNotificationAPSStorage.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct APNSStartLiveActivityNotificationAPSStorage<Attributes: Encodable & Senda
1919
case timestamp = "timestamp"
2020
case event = "event"
2121
case contentState = "content-state"
22+
case staleDate = "stale-date"
2223
case alert = "alert"
2324
case attributes = "attributes"
2425
case attributesType = "attributes-type"
@@ -27,19 +28,22 @@ struct APNSStartLiveActivityNotificationAPSStorage<Attributes: Encodable & Senda
2728
var timestamp: Int
2829
var event: String = "start"
2930
var contentState: ContentState
31+
var staleDate: Int?
3032
var alert: APNSAlertNotificationContent
3133
var attributes: Attributes
3234
var attributesType: String
3335

3436
init(
3537
timestamp: Int,
3638
contentState: ContentState,
39+
staleDate: Int?,
3740
alert: APNSAlertNotificationContent,
3841
attributes: Attributes,
3942
attributesType: String
4043
) {
4144
self.timestamp = timestamp
4245
self.contentState = contentState
46+
self.staleDate = staleDate
4347
self.alert = alert
4448
self.attributes = attributes
4549
self.attributesType = attributesType

Tests/APNSTests/LiveActivity/APNSLiveActivityNotificationTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ final class APNSLiveActivityNotificationTests: XCTestCase {
106106
appID: "test.app.id",
107107
contentState: State(),
108108
timestamp: 1_672_680_658,
109+
staleDate: 1_672_680_800,
109110
attributes: Attributes(),
110111
attributesType: "Attributes",
111112
alert: .init(title: .raw("Hi"), body: .raw("Hello"))
@@ -115,7 +116,8 @@ final class APNSLiveActivityNotificationTests: XCTestCase {
115116
let data = try encoder.encode(notification)
116117

117118
let expectedJSONString = """
118-
{"aps":{"event":"start", "alert": { "title": "Hi", "body": "Hello" }, "attributes-type": "Attributes", "attributes": {"name":"Test Attribute"},"content-state":{"string":"Test","number":123},"timestamp":1672680658}}
119+
{"aps":{"event":"start", "alert": { "title": "Hi", "body": "Hello" }, "attributes-type": "Attributes", "attributes": {"name":"Test Attribute"},"content-state":{"string":"Test","number":123},"timestamp":1672680658,
120+
"stale-date":1672680800}}
119121
"""
120122

121123
let jsonObject1 = try JSONSerialization.jsonObject(with: data) as! NSDictionary

0 commit comments

Comments
 (0)