Add public initializers
This commit is contained in:
parent
96e0da10f3
commit
03426ab3ac
@ -14,4 +14,14 @@ public struct AuthenticatedPushMessage: Codable {
|
|||||||
/// The message to send
|
/// The message to send
|
||||||
public let message: PushMessage
|
public let message: PushMessage
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create an authenticated push message
|
||||||
|
- Parameter sender: The authentication of the sender
|
||||||
|
- Parameter message: The message metadata and content
|
||||||
|
*/
|
||||||
|
public init(sender: DeviceAuthentication, message: PushMessage) {
|
||||||
|
self.sender = sender
|
||||||
|
self.message = message
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,4 +19,14 @@ public struct DeviceAuthentication: Codable {
|
|||||||
*/
|
*/
|
||||||
public let authentication: AuthenticationToken
|
public let authentication: AuthenticationToken
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create a device authentication object.
|
||||||
|
|
||||||
|
- Parameter pushToken: The APNs device token
|
||||||
|
- Parameter authentication: The authentication token generated by the server
|
||||||
|
*/
|
||||||
|
public init(pushToken: PushToken, authentication: AuthenticationToken) {
|
||||||
|
self.pushToken = pushToken
|
||||||
|
self.authentication = authentication
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,15 @@ public struct DeviceDecision: Codable {
|
|||||||
|
|
||||||
/// The hash of the master key to authenticate the request.
|
/// The hash of the master key to authenticate the request.
|
||||||
public let masterKeyHash: Data
|
public let masterKeyHash: Data
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create a decision object to approve or reject a device registration.
|
||||||
|
|
||||||
|
- Parameter pushToken: The APNs device token
|
||||||
|
- Parameter masterKeyHash: The SHA256 hash of the administrator master key.
|
||||||
|
*/
|
||||||
|
public init(pushToken: PushToken, masterKeyHash: Data) {
|
||||||
|
self.pushToken = pushToken
|
||||||
|
self.masterKeyHash = masterKeyHash
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,4 +17,16 @@ public struct DeviceRegistration: Codable {
|
|||||||
The name is displayed when registered users request a list of all devices in an application.
|
The name is displayed when registered users request a list of all devices in an application.
|
||||||
*/
|
*/
|
||||||
public let name: String
|
public let name: String
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create a new device registration object.
|
||||||
|
- Parameter pushToken: The push token to register
|
||||||
|
- Parameter application: The application the device uses
|
||||||
|
- Parameter name: A descriptive name of the device.
|
||||||
|
*/
|
||||||
|
public init(pushToken: PushToken, application: ApplicationId, name: String) {
|
||||||
|
self.pushToken = pushToken
|
||||||
|
self.application = application
|
||||||
|
self.name = name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,15 @@ public struct PushTokenUpdate: Codable {
|
|||||||
|
|
||||||
/// The new push token to register
|
/// The new push token to register
|
||||||
public let newToken: PushToken
|
public let newToken: PushToken
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create a device authentication object.
|
||||||
|
|
||||||
|
- Parameter device: The authentication of the device requesting the change.
|
||||||
|
- Parameter PushToken: The new APNs token to use from now on
|
||||||
|
*/
|
||||||
|
public init(device: DeviceAuthentication, newToken: PushToken) {
|
||||||
|
self.device = device
|
||||||
|
self.newToken = newToken
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,33 @@ public struct PushMessage: Codable {
|
|||||||
In general, the topic is your app’s bundle ID/app ID. It can have a suffix based on the type of push notification. If you’re 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 you’re 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).
|
In general, the topic is your app’s bundle ID/app ID. It can have a suffix based on the type of push notification. If you’re 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 you’re 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).
|
||||||
*/
|
*/
|
||||||
public let topic: String?
|
public let topic: String?
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create a new push message.
|
||||||
|
|
||||||
|
- Parameter recipients: A list of push tokens for all recipients of the message
|
||||||
|
- Parameter payload: The message content and metadata
|
||||||
|
- Parameter pushType: The content type of the message
|
||||||
|
- Parameter topic: The topic id
|
||||||
|
- Parameter expiration: An optional expiration date for the message
|
||||||
|
- Parameter lowPriority: Specify `true` to deliver message with lower priority
|
||||||
|
- Parameter collapseIdentifier: An optional identifier to group push notifications
|
||||||
|
*/
|
||||||
|
public init(recipients: [PushToken],
|
||||||
|
payload: APNSwiftPayload,
|
||||||
|
pushType: APNSwiftConnection.PushType,
|
||||||
|
topic: String,
|
||||||
|
expiration: Date? = nil,
|
||||||
|
lowPriority: Bool = false,
|
||||||
|
collapseIdentifier: String? = nil) {
|
||||||
|
self.recipients = recipients
|
||||||
|
self.payload = payload
|
||||||
|
self.pushType = pushType
|
||||||
|
self.topic = topic
|
||||||
|
self.expiration = expiration
|
||||||
|
self.lowPriority = lowPriority
|
||||||
|
self.collapseIdentifier = collapseIdentifier
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension APNSwiftConnection.PushType: Codable {
|
extension APNSwiftConnection.PushType: Codable {
|
||||||
|
Loading…
Reference in New Issue
Block a user