|
12 | 12 | //
|
13 | 13 | //===----------------------------------------------------------------------===//
|
14 | 14 |
|
15 |
| -public protocol APNSLiveActivityNotificationEvent: Encodable { |
16 |
| - var rawValue: String { get } |
17 |
| -} |
18 |
| - |
19 |
| -public struct APNSLiveActivityNotificationEventUpdate: APNSLiveActivityNotificationEvent { |
20 |
| - public let rawValue = "update" |
21 |
| -} |
22 |
| - |
23 |
| -public struct APNSLiveActivityNotificationEventEnd: APNSLiveActivityNotificationEvent { |
24 |
| - public let rawValue = "end" |
25 |
| -} |
26 | 15 |
|
27 |
| -public protocol APNSLiveActivityNotificationEventStartStateProtocol: Encodable |
28 |
| -{ |
29 |
| - associatedtype State: Encodable |
30 |
| -} |
31 |
| - |
32 |
| -public struct APNSLiveActivityNotificationEventStart<State: Encodable>: |
33 |
| - APNSLiveActivityNotificationEvent, APNSLiveActivityNotificationEventStartStateProtocol |
34 |
| -{ |
35 |
| - public struct Attributes: Encodable { |
36 |
| - public let type: String |
37 |
| - public let state: State |
| 16 | +public struct APNSLiveActivityNotificationEvent: Encodable { |
| 17 | + /// The underlying raw value that is send to APNs. |
| 18 | + @usableFromInline |
| 19 | + internal let rawValue: String |
38 | 20 |
|
39 |
| - public init(type: String, state: State) { |
40 |
| - self.type = type |
41 |
| - self.state = state |
42 |
| - } |
43 |
| - } |
| 21 | + /// Specifies that live activity should be updated |
| 22 | + public static let update = Self(rawValue: "update") |
44 | 23 |
|
45 |
| - public let rawValue = "start" |
46 |
| - public let attributes: Attributes |
47 |
| - public let alert: APNSAlertNotificationContent |
| 24 | + /// Specifies that live activity should be ended |
| 25 | + public static let end = Self(rawValue: "end") |
48 | 26 |
|
49 |
| - public init(attributes: Attributes, alert: APNSAlertNotificationContent) { |
50 |
| - self.attributes = attributes |
51 |
| - self.alert = alert |
52 |
| - } |
| 27 | + /// The underlying raw value that is send to APNs. |
| 28 | + public static let start = Self(rawValue: "start") |
53 | 29 | }
|
54 | 30 |
|
55 |
| -extension APNSLiveActivityNotificationEvent where Self == APNSLiveActivityNotificationEventUpdate { |
56 |
| - public static var update: APNSLiveActivityNotificationEventUpdate { |
57 |
| - APNSLiveActivityNotificationEventUpdate() |
58 |
| - } |
59 |
| -} |
60 |
| - |
61 |
| -extension APNSLiveActivityNotificationEvent where Self == APNSLiveActivityNotificationEventEnd { |
62 |
| - public static var end: APNSLiveActivityNotificationEventEnd { |
63 |
| - APNSLiveActivityNotificationEventEnd() |
64 |
| - } |
65 |
| -} |
| 31 | +public struct APNSLiveActivityNotificationEventStartOptions<State: Encodable> { |
| 32 | + var attributeType: String |
| 33 | + var attributes: State |
| 34 | + var alert: APNSAlertNotificationContent |
66 | 35 |
|
67 |
| -extension APNSLiveActivityNotificationEvent |
68 |
| -where Self: APNSLiveActivityNotificationEventStartStateProtocol { |
69 |
| - public static func start(type: String, state: State, alert: APNSAlertNotificationContent) |
70 |
| - -> APNSLiveActivityNotificationEventStart< |
71 |
| - State |
72 |
| - > |
73 |
| - { |
74 |
| - .init(attributes: .init(type: type, state: state), alert: alert) |
75 |
| - } |
| 36 | + public init(attributeType: String, attributes: State, alert: APNSAlertNotificationContent) { |
| 37 | + self.attributeType = attributeType |
| 38 | + self.attributes = attributes |
| 39 | + self.alert = alert |
| 40 | + } |
76 | 41 | }
|
0 commit comments