Urgency
The urgency with which to deliver a push message.
struct Urgency
The urgency with which to deliver a push message.
struct Urgency
import WebPush
actor WebPushManager
A manager for sending push messages to subscribers.
convenience init(vapidConfiguration: VAPID.Configuration, networkConfiguration: NetworkConfiguration = .default, backgroundActivityLogger: Logger? = .defaultWebPushPrintLogger, eventLoopGroupProvider: NIOEventLoopGroupProvider = .shared(.singletonMultiThreadedEventLoopGroup))
Initialize a manager with a VAPID configuration.
init(vapidConfiguration: VAPID.Configuration, networkConfiguration: NetworkConfiguration = .default, backgroundActivityLogger: Logger, executor: Executor, skipClientShutdown: Bool = false)
Internal method to install a different executor for mocking.
convenience init(vapidConfiguration: VAPID.Configuration, networkConfiguration: NetworkConfiguration = .default, backgroundActivityLogger: Logger? = .defaultWebPushPrintLogger, unsafeHTTPClient: HTTPClient)
Initialize a manager with an unsafe HTTP Client.
static let maximumEncryptedPayloadSize: Int
The maximum encrypted payload size guaranteed by the spec.
static let maximumMessageSize: Int
The maximum message size allowed.
static let messageEncoder: JSONEncoder
The encoder used when serializing JSON messages.
nonisolated let networkConfiguration: NetworkConfiguration
The network configuration used when configuring the manager.
nonisolated var nextVAPIDKeyID: VAPID.Key.ID { get }
Request a VAPID key to supply to the client when requesting a new subscription.
nonisolated let vapidConfiguration: VAPID.Configuration
The VAPID configuration used when configuring the manager.
nonisolated func checkMessageSize(data message: some DataProtocol) throws(MessageTooLargeError)
Check to see if a message is potentially too large to be sent to a push service.
nonisolated func checkMessageSize(json message: some Encodable & Sendable) throws
Check to see if a message is potentially too large to be sent to a push service.
nonisolated func checkMessageSize<Contents>(notification: PushMessage.Notification<Contents>) throws where Contents : Encodable, Contents : Sendable
Check to see if a message is potentially too large to be sent to a push service.
nonisolated func checkMessageSize(string message: some StringProtocol) throws(MessageTooLargeError)
Check to see if a message is potentially too large to be sent to a push service.
nonisolated func keyStatus(for keyID: VAPID.Key.ID) -> VAPID.Configuration.KeyStatus
Check the status of a key against the current configuration.
func run() async throws
func send(data message: some DataProtocol, to subscriber: some SubscriberProtocol, deduplicationTopic topic: Topic? = nil, expiration: Expiration = .recommendedMaximum, urgency: Urgency = .high, logger: Logger? = nil) async throws
Send a push message as raw data.
func send(data message: some DataProtocol, to subscriber: some SubscriberProtocol, encodableDeduplicationTopic: some Encodable, expiration: Expiration = .recommendedMaximum, urgency: Urgency = .high, logger: Logger? = nil) async throws
Send a push message as raw data.
func send(json message: some Encodable & Sendable, to subscriber: some SubscriberProtocol, deduplicationTopic topic: Topic? = nil, expiration: Expiration = .recommendedMaximum, urgency: Urgency = .high, logger: Logger? = nil) async throws
Send a push message as encoded JSON.
func send(json message: some Encodable & Sendable, to subscriber: some SubscriberProtocol, encodableDeduplicationTopic: some Encodable, expiration: Expiration = .recommendedMaximum, urgency: Urgency = .high, logger: Logger? = nil) async throws
Send a push message as encoded JSON.
func send<Contents>(notification: PushMessage.Notification<Contents>, to subscriber: some SubscriberProtocol, deduplicationTopic topic: Topic? = nil, expiration: Expiration = .recommendedMaximum, urgency: Urgency = .high, logger: Logger? = nil) async throws where Contents : Encodable, Contents : Sendable
Send a push notification.
func send<Contents>(notification: PushMessage.Notification<Contents>, to subscriber: some SubscriberProtocol, encodableDeduplicationTopic: some Encodable, expiration: Expiration = .recommendedMaximum, urgency: Urgency = .high, logger: Logger? = nil) async throws where Contents : Encodable, Contents : Sendable
Send a push notification.
func send(string message: some StringProtocol, to subscriber: some SubscriberProtocol, deduplicationTopic topic: Topic? = nil, expiration: Expiration = .recommendedMaximum, urgency: Urgency = .high, logger: Logger? = nil) async throws
Send a push message as a string.
func send(string message: some StringProtocol, to subscriber: some SubscriberProtocol, encodableDeduplicationTopic: some Encodable, expiration: Expiration = .recommendedMaximum, urgency: Urgency = .high, logger: Logger? = nil) async throws
Send a push message as a string.
enum Executor
An internal type representing the executor for a push message.
struct Expiration
A duration in seconds used to express when push messages will expire.
struct NetworkConfiguration
The network configuration for a web push manager.
enum _Message
An internal type representing a push message, accessible when using WebPushTesting
.
protocol Comparable : Equatable
A type that can be compared using the relational operators <
, <=
, >=
, and >
.
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Decodable
A type that can decode itself from an external representation.
protocol Encodable
A type that can encode itself to an external representation.
protocol Equatable
A type that can be compared for value equality.
protocol Escapable
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
protocol Sendable
init(from decoder: Decoder) throws
static let high: WebPushManager.Urgency
An urgency intended for devices even with low battery.
static let low: WebPushManager.Urgency
An urgency intended for devices on either power or Wi-Fi.
static let normal: WebPushManager.Urgency
An urgency intended for devices on neither power nor Wi-Fi.
static let veryLow: WebPushManager.Urgency
An urgency intended only for devices on power and Wi-Fi.
var description: String { get }
static func < (lhs: Self, rhs: Self) -> Bool
func encode(to encoder: Encoder) throws
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.
static func ... (minimum: Self) -> PartialRangeFrom<Self>
Returns a partial range extending upward from a lower bound.
static func ... (maximum: Self) -> PartialRangeThrough<Self>
Returns a partial range up to, and including, its upper bound.
static func ... (minimum: Self, maximum: Self) -> ClosedRange<Self>
Returns a closed range that contains both of its bounds.
static func ..< (maximum: Self) -> PartialRangeUpTo<Self>
Returns a partial range up to, but not including, its upper bound.
static func ..< (minimum: Self, maximum: Self) -> Range<Self>
Returns a half-open range that contains its lower bound but not its upper bound.
static func <= (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func > (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func >= (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.