File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
Sources/ParseSwift/Types/ParsePushPayload/Apple Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,13 @@ public struct ParsePushPayloadApple: ParsePushApplePayloadable {
116
116
117
117
public init ( from decoder: Decoder ) throws {
118
118
let values = try decoder. container ( keyedBy: CodingKeys . self)
119
+ do {
120
+ alert = try values. decode ( ParsePushAppleAlert . self, forKey: . alert)
121
+ } catch {
122
+ if let alertBody = try values. decodeIfPresent ( String . self, forKey: . alert) {
123
+ alert = ParsePushAppleAlert ( body: alertBody)
124
+ }
125
+ }
119
126
relevanceScore = try values. decodeIfPresent ( Double . self, forKey: . relevanceScore)
120
127
targetContentId = try values. decodeIfPresent ( String . self, forKey: . targetContentId)
121
128
mutableContent = try values. decodeIfPresent ( Int . self, forKey: . mutableContent)
@@ -131,14 +138,6 @@ public struct ParsePushPayloadApple: ParsePushApplePayloadable {
131
138
topic = try values. decodeIfPresent ( String . self, forKey: . topic)
132
139
interruptionLevel = try values. decodeIfPresent ( String . self, forKey: . interruptionLevel)
133
140
urlArgs = try values. decodeIfPresent ( [ String ] . self, forKey: . urlArgs)
134
- do {
135
- alert = try values. decode ( ParsePushAppleAlert . self, forKey: . alert)
136
- } catch {
137
- guard let alertBody = try values. decodeIfPresent ( String . self, forKey: . alert) else {
138
- return
139
- }
140
- alert = ParsePushAppleAlert ( body: alertBody)
141
- }
142
141
}
143
142
144
143
/**
Original file line number Diff line number Diff line change @@ -128,6 +128,9 @@ class ParsePushPayloadAppleTests: XCTestCase {
128
128
let anyEncodablePayload = AnyEncodable ( applePayload)
129
129
let anyEncodablePayload2 = AnyEncodable ( decoded)
130
130
XCTAssertEqual ( anyEncodablePayload, anyEncodablePayload2)
131
+ let value = " peace "
132
+ let dictionary = [ anyEncodablePayload: value]
133
+ XCTAssertEqual ( dictionary [ anyEncodablePayload2] , value)
131
134
}
132
135
133
136
func testAppleAlertStringDecode( ) throws {
You can’t perform that action at this time.
0 commit comments