You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It requires sending `ContentState` matching with the live activity configuration to successfully update activity state. `ContentState` needs to conform to `Encodable`
78
+
It requires sending `ContentState` matching with the live activity configuration to successfully update activity state. `ContentState` needs to conform to `Encodable` and `Sendable`.
85
79
86
80
```swift
87
-
tryawait client.sendLiveActivityNotification(
88
-
.init(
89
-
expiration: .immediately,
90
-
priority: .immediately,
91
-
appID: "com.app.bundle",
92
-
contentState: ContentState,
93
-
event: .update,
94
-
timestamp: Int(Date().timeIntervalSince1970)
95
-
),
96
-
activityPushToken: activityPushToken,
97
-
deadline: .distantFuture
98
-
)
81
+
tryawait client.sendLiveActivityNotification(
82
+
.init(
83
+
expiration: .immediately,
84
+
priority: .immediately,
85
+
appID: "com.app.bundle",
86
+
contentState: ContentState,
87
+
event: .update,
88
+
timestamp: Int(Date().timeIntervalSince1970)
89
+
),
90
+
deviceToken: activityPushToken
91
+
)
99
92
```
100
93
101
94
```swift
102
-
tryawait client.sendLiveActivityNotification(
103
-
.init(
104
-
expiration: .immediately,
105
-
priority: .immediately,
106
-
appID: "com.app.bundle",
107
-
contentState: ContentState,
108
-
event: .end,
109
-
timestamp: Int(Date().timeIntervalSince1970),
110
-
dismissalDate: .dismissImmediately// Optional to alter default behaviour
111
-
),
112
-
activityPushToken: activityPushToken,
113
-
deadline: .distantFuture
114
-
)
95
+
tryawait client.sendLiveActivityNotification(
96
+
.init(
97
+
expiration: .immediately,
98
+
priority: .immediately,
99
+
appID: "com.app.bundle",
100
+
contentState: ContentState,
101
+
event: .end,
102
+
timestamp: Int(Date().timeIntervalSince1970),
103
+
dismissalDate: .immediately// Optional to alter default behaviour
104
+
),
105
+
deviceToken: activityPushToken
106
+
)
115
107
```
116
108
## Authentication
117
109
`APNSwift` provides two authentication methods. `jwt`, and `TLS`.
@@ -121,8 +113,8 @@ These can be configured when created your `APNSClientConfiguration`
121
113
122
114
*Notes: `jwt` requires an encrypted version of your .p8 file from Apple which comes in a `pem` format. If you're having trouble with your key being invalid please confirm it is a PEM file*
A non-blocking Swift package for sending remote Apple Push Notification requests to Apple's APNS.
1
+
# ``APNS``
2
+
3
+
A non-blocking Swift module for sending remote Apple Push Notification requests to APNS built on AsyncHttpClient.
3
4
4
5
## Installation
5
6
6
7
To install `APNSwift`, just add the package as a dependency in your [**Package.swift**](https://github.com/apple/swift-package-manager/blob/master/Documentation/PackageDescriptionV4.md#dependencies).
If youd like to give our bleeding edge release a try, which is what the Readme is expecting use `5.0.0-alpha.N`. If you need the old Readme, see [here](https://github.com/swift-server-community/APNSwift/tree/4.0.0)
`APNSwift` is built with a layered approach. It exposes three tiers of API's.
23
-
1. A [raw API](https://github.com/swift-server-community/APNSwift/blob/d60241fe2b6eb193331567a871697d3f4bdf70fb/Sources/APNSwift/APNSClient.swift#L254) that takes basic types such as `String`'s
24
-
2. A slightly more [semantically safe API](https://github.com/swift-server-community/APNSwift/blob/d60241fe2b6eb193331567a871697d3f4bdf70fb/Sources/APNSwift/APNSClient.swift#L183), which takes types, like [`APNSPriority`](https://github.com/swift-server-community/APNSwift/blob/main/Sources/APNSwift/APNSPriority.swift), [`APNSPushType`](https://github.com/swift-server-community/APNSwift/blob/main/Sources/APNSwift/APNSPushType.swift), [`APNSNotificationExpiration`](https://github.com/swift-server-community/APNSwift/blob/main/Sources/APNSwift/APNSNotificationExpiration.swift), etc.
25
-
3. The [safest API](https://github.com/swift-server-community/APNSwift/blob/d60241fe2b6eb193331567a871697d3f4bdf70fb/Sources/APNSwift/Alert/APNSClient%2BAlert.swift#L32) which takes fully semantic types such as [`APNSAlertNotification`](https://github.com/swift-server-community/APNSwift/blob/d60241fe2b6eb193331567a871697d3f4bdf70fb/Sources/APNSwift/Alert/APNSAlertNotification.swift#L177)
26
-
27
-
**We recommened using number 3, the semantically safest API to ensure your push notification is delivered correctly**. *This README assumes that you are using number 3.* However if you need more granular approach, or something doesn't exist in this library, please use 2 or 1. (Also please open an issue if we missed something so we can get a semantically correct version!)
28
14
29
15
## Getting Started
30
-
APNSwift aims to provide sementically correct structures to sending push notifications. You first need to setup a [`APNSClient`](https://github.com/swift-server-community/APNSwift/blob/main/Sources/APNSwift/APNSClient.swift). To do that youll need to know your authentication method
16
+
APNSwift aims to provide semantically correct structures to sending push notifications. You first need to setup a [`APNSClient`](https://github.com/swift-server-community/APNSwift/blob/main/Sources/APNS/APNSClient.swift). To do that youll need to know your authentication method
@@ -85,8 +65,8 @@ These can be configured when created your `APNSClientConfiguration`
85
65
86
66
*Notes: `jwt` requires an encrypted version of your .p8 file from Apple which comes in a `pem` format. If you're having trouble with your key being invalid please confirm it is a PEM file*
By default APNSwift has a no-op logger which will not log anything. However if you pass a logger in, you will see logs.
@@ -98,31 +78,6 @@ This logger can be passed into the `APNSClient` and will log background things l
98
78
#### **Notification Send Logger**
99
79
This logger can be passed into any of the `send:` methods and will log everything related to a single send request.
100
80
101
-
## Using the non semantic safe APIs
102
-
103
-
APNSwift provides the ability to send raw payloads. You can use `Data`, `ByteBuffer`, `DispatchData`, `Array`
104
-
Though this is to be used with caution. APNSwift cannot gurantee delivery if you do not have the correct payload.
105
-
For more information see: [Creating APN Payload](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html)
106
-
107
-
```swift
108
-
/// Extremely Raw,
109
-
tryawait client.send(
110
-
payload: payload,
111
-
deviceToken: token,
112
-
pushType: "alert", deadline: .distantFuture
113
-
)
114
-
115
-
/// or a little safer but still raw
116
-
tryawait client.send(
117
-
payload: payload,
118
-
deviceToken: token,
119
-
pushType: .alert,
120
-
expiration: .immediatly,
121
-
priority: .immediatly,
122
-
deadline: .distantFuture
123
-
)
124
-
```
125
-
126
81
## Server Example
127
82
Take a look at [Program.swift](https://github.com/swift-server-community/APNSwift/blob/main/Sources/APNSwiftExample/Program.swift)
128
83
@@ -136,3 +91,4 @@ Once inside configure your App Bundle ID and assign your development team. Build
136
91
137
92
* Pitch discussion: [Swift Server Forums](https://forums.swift.org/t/apple-push-notification-service-implementation-pitch/20193)
0 commit comments