Skip to content

Commit 8d38084

Browse files
committed
Update InternalIterableAPI.swift
1 parent 3a0f06e commit 8d38084

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

swift-sdk/Internal/InternalIterableAPI.swift

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ import UIKit
77

88
final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
99
var apiKey: String
10-
10+
var lastPushPayload: [AnyHashable: Any]? {
11+
get {
12+
_payloadData
13+
} set {
14+
setPayloadData(newValue)
15+
}
16+
}
17+
1118
var email: String? {
1219
get {
1320
_email
@@ -40,10 +47,6 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
4047
appPackageName: Bundle.main.appPackageName ?? "")
4148
}
4249

43-
var lastPushPayload: [AnyHashable: Any]? {
44-
localStorage.getLastPushPayload(dateProvider.currentDate)
45-
}
46-
4750
var attributionInfo: IterableAttributionInfo? {
4851
get {
4952
localStorage.getAttributionInfo(currentDate: dateProvider.currentDate)
@@ -94,6 +97,11 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
9497
func removeDeviceAttribute(name: String) {
9598
deviceAttributes.removeValue(forKey: name)
9699
}
100+
101+
func setPayloadData(_ data: [AnyHashable: Any]?){
102+
ITBInfo()
103+
_payloadData = data
104+
}
97105

98106
func setEmail(_ email: String?, authToken: String? = nil) {
99107
ITBInfo()
@@ -400,6 +408,7 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
400408
private var deepLinkManager: DeepLinkManager
401409

402410
private var _email: String?
411+
private var _payloadData: [AnyHashable: Any]?
403412
private var _userId: String?
404413

405414
/// the hex representation of this device token
@@ -519,15 +528,15 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
519528
}
520529

521530
private func save(pushPayload payload: [AnyHashable: Any]) {
522-
let expiration = Calendar.current.date(byAdding: .hour,
523-
value: Const.UserDefault.payloadExpiration,
524-
to: dateProvider.currentDate)
525-
localStorage.saveLastPushPayload(payload, withExpiration: expiration)
526531

527532
if let metadata = IterablePushNotificationMetadata.metadata(fromLaunchOptions: payload) {
528533
if let templateId = metadata.templateId {
529534
attributionInfo = IterableAttributionInfo(campaignId: metadata.campaignId, templateId: templateId, messageId: metadata.messageId)
530535
}
536+
537+
if !metadata.isGhostPush {
538+
lastPushPayload = payload
539+
}
531540
}
532541
}
533542

0 commit comments

Comments
 (0)