Skip to content

Commit

Permalink
Merge pull request #1283 from WalletConnect/feature/nullable-message-…
Browse files Browse the repository at this point in the history
…urls

[Notify] Nullable icon and url parsing
  • Loading branch information
flypaper0 authored Jan 23, 2024
2 parents bd97abb + 3ac1823 commit 880b82a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Example/IntegrationTests/Push/NotifyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ final class NotifyTests: XCTestCase {
await fulfillment(of: [subscribeExpectation], timeout: InputConfig.defaultTimeout)

try await walletNotifyClientA.fetchHistory(subscription: subscription)
XCTAssertEqual(walletNotifyClientA.getMessageHistory(topic: subscription.topic).count, 41)
XCTAssertTrue(walletNotifyClientA.getMessageHistory(topic: subscription.topic).count > 40)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,24 @@ public struct NotifyMessage: Codable, Equatable {
return Date(milliseconds: sent_at)
}

public init(id: String, title: String, body: String, icon: String, url: String, type: String, sentAt: Date) {
public init(id: String, title: String, body: String, icon: String?, url: String?, type: String, sentAt: Date) {
self.id = id
self.title = title
self.body = body
self.icon = icon
self.url = url
self.icon = icon ?? ""
self.url = url ?? ""
self.type = type
self.sent_at = UInt64(sentAt.millisecondsSince1970)
}

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.id = try container.decode(String.self, forKey: .id)
self.title = try container.decode(String.self, forKey: .title)
self.body = try container.decode(String.self, forKey: .body)
self.icon = try container.decodeIfPresent(String.self, forKey: .icon) ?? ""
self.url = try container.decodeIfPresent(String.self, forKey: .url) ?? ""
self.type = try container.decode(String.self, forKey: .type)
self.sent_at = try container.decode(UInt64.self, forKey: .sent_at)
}
}

0 comments on commit 880b82a

Please sign in to comment.