@@ -75,19 +75,22 @@ struct LocalStorage: LocalStorageProtocol {
75
75
iterableUserDefaults. save ( attributionInfo: attributionInfo, withExpiration: expiration)
76
76
}
77
77
78
- func getPayload ( currentDate: Date ) -> [ AnyHashable : Any ] ? {
79
- iterableUserDefaults . getPayload ( currentDate: currentDate)
78
+ func getLastPushPayload ( _ currentDate: Date ) -> [ AnyHashable : Any ] ? {
79
+ return keychain . getLastPushPayload ( currentDate: currentDate)
80
80
}
81
81
82
- func save ( payload: [ AnyHashable : Any ] ? , withExpiration expiration: Date ? ) {
83
- iterableUserDefaults . save ( payload : payload, withExpiration: expiration)
82
+ func saveLastPushPayload ( _ payload: [ AnyHashable : Any ] ? , withExpiration expiration: Date ? ) {
83
+ keychain . setLastPushPayload ( payload, withExpiration: expiration)
84
84
}
85
85
86
86
func upgrade( ) {
87
87
ITBInfo ( )
88
88
89
89
/// moves `email`, `userId`, and `authToken` from `UserDefaults` to `IterableKeychain`
90
90
moveAuthDataFromUserDefaultsToKeychain ( )
91
+
92
+ /// moves `lastPushPayload` from `UserDefaults` to `IterableKeychain`
93
+ moveLastPushPayloadFromUserDefaultsToKeychain ( )
91
94
}
92
95
93
96
// MARK: Private
@@ -117,4 +120,13 @@ struct LocalStorage: LocalStorageProtocol {
117
120
ITBInfo ( " UPDATED: moved userId from UserDefaults to IterableKeychain " )
118
121
}
119
122
}
123
+
124
+ private func moveLastPushPayloadFromUserDefaultsToKeychain( ) {
125
+ // using current date rather than `DateProvider` for convenience
126
+ if let ( userDefaultLastPushPayload, expiration) = iterableUserDefaults. getLastPushPayloadAndExpirationPair ( ) {
127
+ keychain. setLastPushPayload ( userDefaultLastPushPayload, withExpiration: expiration)
128
+
129
+ ITBInfo ( " UPDATED: moved lastPushPayload from UserDefaults to IterableKeychain " )
130
+ }
131
+ }
120
132
}
0 commit comments