diff --git a/Sources/FCM/FCMAndroidConfig/FCMAndroidConfig.swift b/Sources/FCM/FCMAndroidConfig/FCMAndroidConfig.swift index 1fb78b6..8ec17ef 100644 --- a/Sources/FCM/FCMAndroidConfig/FCMAndroidConfig.swift +++ b/Sources/FCM/FCMAndroidConfig/FCMAndroidConfig.swift @@ -1,4 +1,4 @@ -public struct FCMAndroidConfig: Codable { +public struct FCMAndroidConfig: Codable, Equatable { /// An identifier of a group of messages that can be collapsed, so that only the last message gets sent when delivery can be resumed. /// A maximum of 4 different collapse keys is allowed at any given time. public var collapse_key: String? diff --git a/Sources/FCM/FCMAndroidConfig/FCMAndroidMessagePriority.swift b/Sources/FCM/FCMAndroidConfig/FCMAndroidMessagePriority.swift index 390eca5..195ec44 100644 --- a/Sources/FCM/FCMAndroidConfig/FCMAndroidMessagePriority.swift +++ b/Sources/FCM/FCMAndroidConfig/FCMAndroidMessagePriority.swift @@ -1,4 +1,4 @@ -public enum FCMAndroidMessagePriority: String, Codable { +public enum FCMAndroidMessagePriority: String, Codable, Equatable { /// Default priority for data messages. /// Normal priority messages won't open network connections on a sleeping device, /// and their delivery may be delayed to conserve the battery. diff --git a/Sources/FCM/FCMAndroidConfig/FCMAndroidNotification.swift b/Sources/FCM/FCMAndroidConfig/FCMAndroidNotification.swift index be42663..a888017 100644 --- a/Sources/FCM/FCMAndroidConfig/FCMAndroidNotification.swift +++ b/Sources/FCM/FCMAndroidConfig/FCMAndroidNotification.swift @@ -1,4 +1,4 @@ -public struct FCMAndroidNotification: Codable { +public struct FCMAndroidNotification: Codable, Equatable { /// The notification's title. /// If present, it will override FCMNotification.title. public var title: String? diff --git a/Sources/FCM/FCMApnsConfig/FCMApnsAlert.swift b/Sources/FCM/FCMApnsConfig/FCMApnsAlert.swift index f4595d6..bcd273c 100644 --- a/Sources/FCM/FCMApnsConfig/FCMApnsAlert.swift +++ b/Sources/FCM/FCMApnsConfig/FCMApnsAlert.swift @@ -1,4 +1,4 @@ -public struct FCMApnsAlert: Codable { +public struct FCMApnsAlert: Codable, Equatable { /// The title of the notification. /// Apple Watch displays this string in the short look notification interface. /// Specify a string that is quickly understood by the user. diff --git a/Sources/FCM/FCMApnsConfig/FCMApnsAlertOrString.swift b/Sources/FCM/FCMApnsConfig/FCMApnsAlertOrString.swift index 5d584d4..ab75da8 100644 --- a/Sources/FCM/FCMApnsConfig/FCMApnsAlertOrString.swift +++ b/Sources/FCM/FCMApnsConfig/FCMApnsAlertOrString.swift @@ -1,5 +1,5 @@ /// Internal helper for different alert payload types -public enum FCMApnsAlertOrString: Codable { +public enum FCMApnsAlertOrString: Codable, Equatable { public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() if let string = try? container.decode(String.self) { @@ -30,14 +30,14 @@ public enum FCMApnsAlertOrString: Codable { return .string(v) } - public var alertPayload: FCMApnsAlert? { + public var asPayload: FCMApnsAlert? { if case let .alert(payload) = self { return payload } return nil } - public var alertMessage: String? { + public var asMessage: String? { if case let .string(message) = self { return message } diff --git a/Sources/FCM/FCMApnsConfig/FCMApnsApsObject.swift b/Sources/FCM/FCMApnsConfig/FCMApnsApsObject.swift index c0d6a20..bc2683a 100644 --- a/Sources/FCM/FCMApnsConfig/FCMApnsApsObject.swift +++ b/Sources/FCM/FCMApnsConfig/FCMApnsApsObject.swift @@ -1,6 +1,6 @@ // The following struct is based on // https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification -public class FCMApnsApsObject: Codable { +public struct FCMApnsApsObject: Codable, Equatable { /// The information for displaying an alert. /// A dictionary is recommended. /// If you specify a string, the alert displays your string as the body text. @@ -79,13 +79,13 @@ public class FCMApnsApsObject: Codable { return FCMApnsApsObject(alertString: nil, sound: "default") } - public convenience init(alertString: String?, - badge: Int? = nil, - sound: String?, - contentAvailable: Bool? = nil, - category: String? = nil, - threadId: String? = nil, - mutableContent: Bool? = nil) { + public init(alertString: String?, + badge: Int? = nil, + sound: String?, + contentAvailable: Bool? = nil, + category: String? = nil, + threadId: String? = nil, + mutableContent: Bool? = nil) { self.init(config: Config(alert: FCMApnsAlertOrString.fromRaw(alertString), badge: badge, sound: sound, @@ -95,13 +95,13 @@ public class FCMApnsApsObject: Codable { mutableContent: mutableContent)) } - public convenience init(alert: FCMApnsAlert? = nil, - badge: Int? = nil, - sound: String?, - contentAvailable: Bool? = nil, - category: String? = nil, - threadId: String? = nil, - mutableContent: Bool? = nil) { + public init(alert: FCMApnsAlert? = nil, + badge: Int? = nil, + sound: String?, + contentAvailable: Bool? = nil, + category: String? = nil, + threadId: String? = nil, + mutableContent: Bool? = nil) { self.init(config: Config(alert: FCMApnsAlertOrString.fromRaw(alert), badge: badge, sound: sound, diff --git a/Sources/FCM/FCMApnsConfig/FCMApnsPayload.swift b/Sources/FCM/FCMApnsConfig/FCMApnsPayload.swift index c51c95c..743007a 100644 --- a/Sources/FCM/FCMApnsConfig/FCMApnsPayload.swift +++ b/Sources/FCM/FCMApnsConfig/FCMApnsPayload.swift @@ -1,8 +1,8 @@ -/// Default APNS payload class +/// Default APNS payload model /// it contains aps dictionary inside /// you can use your own custom payload class /// it just should conform to FCMApnsPayloadProtocol -public class FCMApnsPayload: FCMApnsPayloadProtocol { +public struct FCMApnsPayload: FCMApnsPayloadProtocol, Equatable { /// The APS object, primary alert public var aps: FCMApnsApsObject diff --git a/Sources/FCM/FCMApnsConfig/FCMApnsPayloadProtocol.swift b/Sources/FCM/FCMApnsConfig/FCMApnsPayloadProtocol.swift index b2ce221..ad8b48b 100644 --- a/Sources/FCM/FCMApnsConfig/FCMApnsPayloadProtocol.swift +++ b/Sources/FCM/FCMApnsConfig/FCMApnsPayloadProtocol.swift @@ -1,7 +1,7 @@ -/// Use it for your custom payload class +/// Use it for your custom payload model /// /// Example code: -/// class MyCustomPayload: FCMApnsPayloadProtocol { +/// struct MyCustomPayload: FCMApnsPayloadProtocol { /// var aps: FCMApnsApsObject /// var myCustomKey: String /// @@ -10,6 +10,6 @@ /// self.myCustomKey = myCustomKey /// } /// } -public protocol FCMApnsPayloadProtocol: Codable { +public protocol FCMApnsPayloadProtocol: Codable, Equatable { var aps: FCMApnsApsObject { get set } }