@@ -75,19 +75,22 @@ struct LocalStorage: LocalStorageProtocol {
7575 iterableUserDefaults. save ( attributionInfo: attributionInfo, withExpiration: expiration)
7676 }
7777
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)
8080 }
8181
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)
8484 }
8585
8686 func upgrade( ) {
8787 ITBInfo ( )
8888
8989 /// moves `email`, `userId`, and `authToken` from `UserDefaults` to `IterableKeychain`
9090 moveAuthDataFromUserDefaultsToKeychain ( )
91+
92+ /// moves `lastPushPayload` from `UserDefaults` to `IterableKeychain`
93+ moveLastPushPayloadFromUserDefaultsToKeychain ( )
9194 }
9295
9396 // MARK: Private
@@ -117,4 +120,13 @@ struct LocalStorage: LocalStorageProtocol {
117120 ITBInfo ( " UPDATED: moved userId from UserDefaults to IterableKeychain " )
118121 }
119122 }
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+ }
120132}
0 commit comments