diff --git a/Sources/PushAPI/PushMessage.swift b/Sources/PushAPI/PushMessage.swift index fd62df0..235e862 100644 --- a/Sources/PushAPI/PushMessage.swift +++ b/Sources/PushAPI/PushMessage.swift @@ -49,13 +49,6 @@ public struct PushMessage: Codable { */ public let collapseIdentifier: String? - /** - The topic for the notification. - - 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? - /** Create a new push message. @@ -70,14 +63,12 @@ public struct PushMessage: Codable { 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 @@ -87,3 +78,24 @@ public struct PushMessage: Codable { extension APNSwiftConnection.PushType: Codable { } + +extension APNSwiftConnection.PushType { + + /// The extension to add to the push topic depending on the notification type + var topicExtension: String { + switch self { + case .alert, .background: + return "" + case .mdm: + return "" + case .voip: + return ".voip" + case .fileprovider: + return ".pushkit.fileprovider" + //case .location: + // return ".location-query" + //case .complication: + // return ".complication" + } + } +}