Skip to content

Commit de0e838

Browse files
Merge pull request #283 from Iterable/feature/mob-1360-modify-sdk
[MOB-1360] - Add method getMessage(withId id: String) to IterableInAppManagerProtocol
2 parents 2596c59 + 6fea734 commit de0e838

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

swift-sdk/Internal/EmptyInAppManager.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ class EmptyInAppManager: IterableInternalInAppManagerProtocol {
3838

3939
func set(read _: Bool, forMessage _: IterableInAppMessage) {}
4040

41+
func getMessage(withId _: String) -> IterableInAppMessage? {
42+
return nil
43+
}
44+
4145
func getUnreadInboxMessagesCount() -> Int {
4246
return 0
4347
}

swift-sdk/Internal/InAppManager.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
182182
}
183183
}
184184

185+
func getMessage(withId id: String) -> IterableInAppMessage? {
186+
return messagesMap[id]
187+
}
188+
185189
func isOkToShowNow(message: IterableInAppMessage) -> Bool {
186190
guard message.didProcessTrigger == false else {
187191
ITBInfo("message with id: \(message.messageId) is already processed")

swift-sdk/IterableMessaging.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ import UIKit
4848
/// - parameter read: Whether this inbox message was read
4949
/// - parameter message: The inbox message
5050
@objc(setRead:forMessage:) func set(read: Bool, forMessage message: IterableInAppMessage)
51+
52+
/// - parameter id: The id of the message
53+
/// - returns: IterableInAppMessage with the id, if it exists.
54+
@objc(getMessageWithId:) func getMessage(withId id: String) -> IterableInAppMessage?
5155
}
5256

5357
/// Iterable Notification names

tests/swift-sdk-swift-tests/OrderedDictionaryTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,10 @@ class OrderedDictionaryTests: XCTestCase {
3939

4040
XCTAssertEqual(dict["key"], "value")
4141
}
42+
43+
func testNonExistentKey() {
44+
let dict = OrderedDictionary<String, String>()
45+
46+
XCTAssertNil(dict["key"])
47+
}
4248
}

0 commit comments

Comments
 (0)