Push-Definitions/Sources/PushAPI/PushMessage.swift

63 lines
3.1 KiB
Swift
Raw Normal View History

2022-06-05 11:47:58 +02:00
import APNSwift
import Foundation
/**
A push message to send to other devices.
This structure contains the content of the notification, as well as all data to send the notification to one or more recipients.
*/
2022-06-05 12:10:38 +02:00
public struct PushMessage: Codable {
2022-06-05 11:47:58 +02:00
/**
A list of push tokens for all recipients of the message
*/
2022-06-05 12:13:47 +02:00
public let recipients: [PushToken]
2022-06-05 11:47:58 +02:00
/**
The notification content.
*/
2022-06-05 12:13:47 +02:00
public let payload: APNSwiftPayload
2022-06-05 11:47:58 +02:00
/**
The value of this header must accurately reflect the contents of your notifications payload.
If theres a mismatch, or if the header is missing on required systems, APNs may return an error, delay the delivery of the notification, or drop it altogether.
- Note: Required for watchOS 6 and later; recommended for macOS, iOS, tvOS, and iPadOS
*/
2022-06-05 12:13:47 +02:00
public let pushType: APNSwiftConnection.PushType
2022-06-05 11:47:58 +02:00
/**
The date at which the notification is no longer valid.
If the value is not `nil`, APNs stores the notification and tries to deliver it at least once, repeating the attempt as needed until the specified date. If the value is `nil`, APNs attempts to deliver the notification only once and doesnt store it.
A single APNs attempt may involve retries over multiple network interfaces and connections of the destination device. Often these retries span over some time period, depending on the network characteristics. In addition, a push notification may take some time on the network after APNs sends it to the device. APNs uses best efforts to honor the expiry date without any guarantee. If the value is not `nil`, the notification may be delivered after the mentioned date. If the value is `nil`, the notification may be delivered with some delay.
*/
2022-06-05 12:13:47 +02:00
public let expiration: Date?
2022-06-05 11:47:58 +02:00
/**
The priority of the notification.
Set `lowPriority = false` to send the notification immediately.
Set `lowPriority = true` to send the notification based on power considerations on the users device.
*/
2022-06-05 12:13:47 +02:00
public let lowPriority: Bool
2022-06-05 11:47:58 +02:00
/**
An identifier you use to coalesce multiple notifications into a single notification for the user.
Typically, each notification request causes a new notification to be displayed on the users device. When sending the same notification more than once, use the same value in this header to coalesce the requests. The value of this key must not exceed 64 bytes.
*/
2022-06-05 12:13:47 +02:00
public let collapseIdentifier: String?
2022-06-05 11:47:58 +02:00
/**
The topic for the notification.
In general, the topic is your apps bundle ID/app ID. It can have a suffix based on the type of push notification. If youre using a certificate that supports PushKit VoIP or watchOS complication notifications, you must include this header with bundle ID of you app and if applicable, the proper suffix. If youre using token-based authentication with APNs, you must include this header with the correct bundle ID and suffix combination. To learn more about app ID, see [Register an App ID](https://help.apple.com/developer-account/#/dev1b35d6f83).
*/
2022-06-05 12:13:47 +02:00
public let topic: String?
2022-06-05 11:47:58 +02:00
}
extension APNSwiftConnection.PushType: Codable {
}