Skip to content

Commit

Permalink
Merge pull request #586 from Iterable/MOB-5337-InAppDisplayInterval-r…
Browse files Browse the repository at this point in the history
…esolution
  • Loading branch information
Ayyanchira authored Dec 28, 2022
2 parents 1e25b42 + 9ed89ea commit 9231662
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion swift-sdk/Internal/DependencyContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension DependencyContainerProtocol {
applicationStateProvider: applicationStateProvider,
notificationCenter: notificationCenter,
dateProvider: dateProvider,
retryInterval: config.inAppDisplayInterval)
moveToForegroundSyncInterval: config.inAppDisplayInterval)
}

func createAuthManager(config: IterableConfig) -> IterableAuthManagerProtocol {
Expand Down
17 changes: 8 additions & 9 deletions swift-sdk/Internal/InAppManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
applicationStateProvider: ApplicationStateProviderProtocol,
notificationCenter: NotificationCenterProtocol,
dateProvider: DateProviderProtocol,
retryInterval: Double) {
moveToForegroundSyncInterval: Double) {
ITBInfo()

self.requestHandler = requestHandler
Expand All @@ -56,7 +56,7 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
self.applicationStateProvider = applicationStateProvider
self.notificationCenter = notificationCenter
self.dateProvider = dateProvider
self.retryInterval = retryInterval
self.moveToForegroundSyncInterval = moveToForegroundSyncInterval

super.init()

Expand Down Expand Up @@ -391,7 +391,7 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
// How long do we have to wait before showing the message
// > 0 means wait, otherwise we are good to show
private func getInAppShowingWaitTimeInterval() -> TimeInterval {
InAppManager.getWaitTimeInterval(fromLastTime: lastDismissedTime, currentTime: dateProvider.currentDate, gap: retryInterval)
InAppManager.getWaitTimeInterval(fromLastTime: lastDismissedTime, currentTime: dateProvider.currentDate, gap: moveToForegroundSyncInterval)
}

// How long do we have to wait?
Expand Down Expand Up @@ -521,7 +521,6 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
private let persister: InAppPersistenceProtocol
private var messagesMap = OrderedDictionary<String, IterableInAppMessage>()
private let dateProvider: DateProviderProtocol
private let retryInterval: TimeInterval // in seconds, if a message is already showing how long to wait?
private var lastDismissedTime: Date?
private var lastDisplayTime: Date?

Expand All @@ -532,7 +531,7 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {

private var syncResult: Pending<Bool, Error>?
private var lastSyncTime: Date?
private let moveToForegroundSyncInterval: Double = 1.0 * 60.0 // don't sync within sixty seconds
private var moveToForegroundSyncInterval: Double = 1.0 * 60.0 // don't sync within sixty seconds
private var autoDisplayPaused = false
}

Expand Down Expand Up @@ -621,13 +620,13 @@ extension InAppManager: InAppDisplayChecker {
return false
}

guard InAppManager.getWaitTimeInterval(fromLastTime: lastDismissedTime, currentTime: dateProvider.currentDate, gap: retryInterval) <= 0 else {
ITBInfo("can't display within retryInterval window")
guard InAppManager.getWaitTimeInterval(fromLastTime: lastDismissedTime, currentTime: dateProvider.currentDate, gap: moveToForegroundSyncInterval) <= 0 else {
ITBInfo("can't display within configured In-App display interval window")
return false
}

guard InAppManager.getWaitTimeInterval(fromLastTime: lastDisplayTime, currentTime: dateProvider.currentDate, gap: retryInterval) <= 0 else {
ITBInfo("can't display within retryInterval window")
guard InAppManager.getWaitTimeInterval(fromLastTime: lastDisplayTime, currentTime: dateProvider.currentDate, gap: moveToForegroundSyncInterval) <= 0 else {
ITBInfo("can't display within configured In-App display window")
return false
}

Expand Down

0 comments on commit 9231662

Please sign in to comment.