File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,21 @@ class IterableUserDefaults {
82
82
try ? save ( dict: payload, withKey: . payload, andExpiration: expiration)
83
83
}
84
84
85
+ func getLastPushPayloadAndExpirationPair( ) -> ( payload: [ AnyHashable : Any ] ? , expiration: Date ? ) ? {
86
+ guard let encodedEnvelope = userDefaults. value ( forKey: UserDefaultsKey . payload. value) as? Data else {
87
+ return nil
88
+ }
89
+
90
+ do {
91
+ let envelope = try JSONDecoder ( ) . decode ( Envelope . self, from: encodedEnvelope)
92
+ let decoded = try JSONSerialization . jsonObject ( with: envelope. payload, options: [ ] ) as? [ AnyHashable : Any ]
93
+
94
+ return ( payload: decoded, envelope. expiration)
95
+ } catch {
96
+ return nil
97
+ }
98
+ }
99
+
85
100
// MARK: Private implementation
86
101
87
102
private let userDefaults : UserDefaults
You can’t perform that action at this time.
0 commit comments