Skip to content

Commit 934357e

Browse files
Inbox session manager use non-static inAppManager.
1 parent aa0d36e commit 934357e

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

swift-sdk.xcodeproj/xcshareddata/xcschemes/swift-sdk.xcscheme

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@
106106
BlueprintName = "swift-sdk-swift-tests"
107107
ReferencedContainer = "container:swift-sdk.xcodeproj">
108108
</BuildableReference>
109-
<SkippedTests>
110-
<Test
111-
Identifier = "InboxSessionManagerTests">
112-
</Test>
113-
</SkippedTests>
114109
</TestableReference>
115110
<TestableReference
116111
skipped = "NO">

swift-sdk/Internal/InboxSessionManager.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class InboxSessionManager {
2626
return sessionStartInfo != nil
2727
}
2828

29+
init(provideInAppManager: @escaping @autoclosure () -> IterableInAppManagerProtocol = IterableAPI.inAppManager) {
30+
self.provideInAppManager = provideInAppManager
31+
}
32+
2933
func updateVisibleRows(visibleRows: [InboxImpressionTracker.RowInfo]) {
3034
guard let impressionTracker = impressionTracker else {
3135
ITBError("Expecting impressionTracker here.")
@@ -47,8 +51,8 @@ class InboxSessionManager {
4751

4852
sessionStartInfo = SessionStartInfo(id: IterableUtil.generateUUID(),
4953
startTime: Date(),
50-
totalMessageCount: IterableAPI.inAppManager.getInboxMessages().count,
51-
unreadMessageCount: IterableAPI.inAppManager.getUnreadInboxMessagesCount())
54+
totalMessageCount: provideInAppManager().getInboxMessages().count,
55+
unreadMessageCount: provideInAppManager().getUnreadInboxMessagesCount())
5256
impressionTracker = InboxImpressionTracker()
5357
updateVisibleRows(visibleRows: visibleRows)
5458
}
@@ -67,4 +71,6 @@ class InboxSessionManager {
6771

6872
return sessionInfo
6973
}
74+
75+
private let provideInAppManager: () -> IterableInAppManagerProtocol
7076
}

tests/swift-sdk-swift-tests/InboxSessionManagerTests.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class InboxSessionManagerTests: XCTestCase {
1818
}
1919

2020
func testSessionIsTracking() {
21-
let inboxSessionManager = InboxSessionManager()
21+
let internalApi = IterableAPIInternal.initializeForTesting()
22+
let inboxSessionManager = InboxSessionManager(provideInAppManager: internalApi.inAppManager)
2223

2324
XCTAssertNil(inboxSessionManager.sessionStartInfo)
2425
XCTAssertFalse(inboxSessionManager.isTracking)
@@ -35,7 +36,8 @@ class InboxSessionManagerTests: XCTestCase {
3536
}
3637

3738
func testSessionInfoStartAndEnd() {
38-
let inboxSessionManager = InboxSessionManager()
39+
let internalApi = IterableAPIInternal.initializeForTesting()
40+
let inboxSessionManager = InboxSessionManager(provideInAppManager: internalApi.inAppManager)
3941

4042
inboxSessionManager.startSession(visibleRows: [])
4143

@@ -69,7 +71,8 @@ class InboxSessionManagerTests: XCTestCase {
6971
let rowInfo1 = InboxImpressionTracker.RowInfo(messageId: IterableUtil.generateUUID(), silentInbox: false)
7072
let rowInfo2 = InboxImpressionTracker.RowInfo(messageId: IterableUtil.generateUUID(), silentInbox: true)
7173

72-
let inboxSessionManager = InboxSessionManager()
74+
let internalApi = IterableAPIInternal.initializeForTesting()
75+
let inboxSessionManager = InboxSessionManager(provideInAppManager: internalApi.inAppManager)
7376

7477
let initialVisibleImpressions = [rowInfo1]
7578

0 commit comments

Comments
 (0)