Skip to content

Instantly share code, notes, and snippets.

Created November 21, 2016 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/498030a95a6f74cf03942935a59e68e7 to your computer and use it in GitHub Desktop.
Save anonymous/498030a95a6f74cf03942935a59e68e7 to your computer and use it in GitHub Desktop.
struct PayloadTransform: TransformType {
typealias Object = [DCNotificationPayloadKey: Any]
typealias JSON = [String: Any]
func transformFromJSON(_ value: Any?) -> [DCNotificationPayloadKey: Any]? {
guard let value = value as? [String: Any] else {
return [:]
}
var result = [AppNotificationPayloadKey: Any]()
for (key, value) in value {
if let payloadKey = DCNotificationPayloadKey(rawValue: key) {
result[payloadKey] = value
}
}
return result
}
func transformToJSON(_ value: [DCNotificationPayloadKey: Any]?) -> [String: Any]? {
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment