send(json:to:deduplicationTopic:expiration:urgency:logger:)

Send a push message as encoded JSON.

WebPushManager.swift:477
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

Parameters

message

The message to send as JSON.

subscriber

The subscriber to send the push message to.

deduplicationTopic

The topic to use when deduplicating messages stored on a Push Service. When specifying a topic, prefer to use send(json:to:encodableDeduplicationTopic:expiration:urgency:logger:) instead.

expiration

The expiration of the push message, after wich delivery will no longer be attempted.

urgency

The urgency of the delivery of the push message.

logger

The logger to use for status updates. If not provided, the background activity logger will be used instead. When running in a server environment, your contextual logger should be used instead giving you full control of logging and metadata.

The service worker you registered is expected to know how to decode the JSON you send. Note that dates are encoded using millisecondsSince1970, and data is encoded using base64.