Skip to content

Commit cc760f3

Browse files
committed
[MOB-9233] Updated code according to the new discussion
1 parent df6a01d commit cc760f3

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
</BuildAction>
8181
<TestAction
8282
buildConfiguration = "Debug"
83-
selectedDebuggerIdentifier = ""
84-
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
83+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
84+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
8585
shouldUseLaunchSchemeArgsEnv = "YES"
8686
codeCoverageEnabled = "YES"
8787
onlyGenerateCoverageForSpecifiedTargets = "YES">

swift-sdk/Internal/in-app/InAppMessageParser.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ struct InAppMessageParser {
8282
}
8383

8484
let jsonOnly = (json[JsonKey.InApp.jsonOnly] as? Int ?? 0) == 1
85-
let customPayload = parseCustomPayload(fromPayload: json)
85+
var customPayload = parseCustomPayload(fromPayload: json)
86+
87+
if jsonOnly && customPayload == nil {
88+
customPayload = [:]
89+
}
8690

8791
// For non-JSON-only messages, we require content
8892
if !jsonOnly {

swift-sdk/Internal/in-app/InAppPersistence.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,10 @@ extension IterableInAppMessage: Codable {
255255

256256
let jsonOnly = (try? container.decode(Int.self, forKey: .jsonOnly)) ?? 0
257257
let customPayloadData = try? container.decode(Data.self, forKey: .customPayload)
258-
let customPayload = IterableInAppMessage.deserializeCustomPayload(withData: customPayloadData)
258+
var customPayload = IterableInAppMessage.deserializeCustomPayload(withData: customPayloadData)
259259

260-
// For JSON-only messages, require customPayload
261260
if jsonOnly == 1 && customPayload == nil {
262-
ITBError("JSON-only message requires customPayload")
263-
self.init(messageId: "",
264-
campaignId: 0,
265-
content: IterableInAppMessage.createDefaultContent(),
266-
jsonOnly: false)
267-
return
261+
customPayload = [:]
268262
}
269263

270264
let saveToInbox = (try? container.decode(Bool.self, forKey: .saveToInbox)) ?? false

tests/unit-tests/InAppTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,7 @@ class InAppTests: XCTestCase {
16711671
XCTAssertEqual(messages.count, 1)
16721672

16731673
let message = messages[0]
1674-
XCTAssertTrue(message.customPayload == nil)
1674+
XCTAssertTrue(message.customPayload?.isEmpty ?? false)
16751675
expectation1.fulfill()
16761676
}
16771677

0 commit comments

Comments
 (0)