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
Copy file name to clipboardExpand all lines: doc/provider.markdown
+29-6Lines changed: 29 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -63,13 +63,36 @@ The `Provider` can continue to be used for sending notifications and the counter
63
63
64
64
## Class: apn.Provider
65
65
66
+
`apn.Provider` provides a number of methods for sending notifications, broadcasting notifications, and managing channels. Calling any of the methods will return a `Promise` for each notification and is discussed more in [Results from APN Provider Methods](#results-from-apnprovider-methods).
67
+
66
68
### connection.send(notification, recipients)
67
69
68
-
This is main interface for sending notifications. Create a `Notification` object and pass it in, along with a single recipient or an array of them and node-apn will take care of the rest, delivering a copy of the notification to each recipient.
70
+
This is the main interface for sending notifications. Create a `Notification` object and pass it in, along with a single recipient or an array of them and node-apn will take care of the rest, delivering a copy of the notification to each recipient.
69
71
70
72
> A "recipient" is a `String` containing the hex-encoded device token.
71
73
72
-
Calling `send` will return a `Promise`. The Promise will resolve after each notification (per token) has reached a final state. Each notification can end in one of three possible states:
74
+
Calling `send` will return a `Promise`. The Promise will resolve after each notification (per token) has reached a final state.
This is the interface for managing broadcast channels. Create a single `Notification` object or an aray of them and pass the notification(s) in, along with a bundleId, and an action (`create`, `read`, `readAll`, `delete`) and node-apn will take care of the rest, asking the APNs to perform the action using the criteria specified in each notification.
78
+
79
+
> A "bundleId" is a `String` containing bundle identifier for the application.
80
+
81
+
> An "action" is a `String` containing: `create`, `read`, `readAll`, or `delete` and represents what action to perform with a channel (See more in [Apple Documentation](https://developer.apple.com/documentation/usernotifications/sending-channel-management-requests-to-apns)).
82
+
83
+
Calling `manageChannels` will return a `Promise`. The Promise will resolve after each notification has reached a final state.
84
+
85
+
### connection.broadcast(notification, bundleId)
86
+
87
+
This is the interface for broadcasting Live Activity notifications. Create a single `Notification` object or an aray of them and pass the notification(s) in, along with a bundleId and node-apn will take care of the rest, asking the APNs to broadcast using the criteria specified in each notification.
88
+
89
+
> A "bundleId" is a `String` containing bundle identifier for the application.
90
+
91
+
Calling `broadcast` will return a `Promise`. The Promise will resolve after each notification has reached a final state.
92
+
93
+
### Results from apn.Provider methods
94
+
95
+
Each notification can end in one of three possible states:
73
96
74
97
-`sent` - the notification was accepted by Apple for delivery to the given recipient
75
98
-`failed` (rejected) - the notification was rejected by Apple. A rejection has an associated `status` and `reason` which is included.
@@ -79,15 +102,15 @@ When the returned `Promise` resolves, its value will be an Object containing two
79
102
80
103
#### sent
81
104
82
-
An array of device tokens to which the notification was successfully sent and accepted by Apple.
105
+
An array of device tokens or bundle identifiers to which the notification was successfully sent and accepted by Apple.
83
106
84
107
Being `sent` does **not** guarantee the notification will be _delivered_, other unpredictable factors - including whether the device is reachable - can ultimately prevent delivery.
85
108
86
109
#### failed
87
110
88
-
An array of objects for each failed token. Each object will contain the device token which failed and details of the failure which will differ between rejected and errored notifications.
111
+
An array of objects for each failed token or bundle identifier. Each object will contain the device token or bundle identifier which failed and details of the failure which will differ between rejected and errored notifications.
89
112
90
-
For **rejected** notifications the object will take the following form
113
+
For **rejected** notifications using `send()`, the object will take the following form
91
114
92
115
```javascript
93
116
{
@@ -101,7 +124,7 @@ For **rejected** notifications the object will take the following form
101
124
102
125
More details about the response and associated status codes can be found in the [HTTP/2 Response from APN documentation][http2-response].
103
126
104
-
If a failed notification was instead caused by an **error** then it will have an `error` property instead of `response` and `status`:
127
+
If a failed notification using `send()`was instead caused by an **error** then it will have an `error` property instead of `response` and `status`:
0 commit comments