Skip to content

Commit 5848b4e

Browse files
Fixed channel deserialisation in iOS (#8386)
* Fixed channel * Change file
1 parent 803c3a7 commit 5848b4e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.changes/fix-ios-channel.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": 'patch:enhance'
3+
---
4+
5+
Fixed the deserialisation of a `Channel` in iOS.

core/tauri/mobile/ios-api/Sources/Tauri/Channel.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let channelDataKey = CodingUserInfoKey(rawValue: "sendChannelData")!
99

1010
public class Channel: Decodable {
1111
public let id: UInt64
12-
let handler: (String) -> Void
12+
let handler: (UInt64, String) -> Void
1313

1414
public required init(from decoder: Decoder) throws {
1515
let container = try decoder.singleValueContainer()
@@ -30,7 +30,7 @@ public class Channel: Decodable {
3030
)
3131
}
3232

33-
guard let handler = decoder.userInfo[channelDataKey] as? (String) -> Void else {
33+
guard let handler = decoder.userInfo[channelDataKey] as? (UInt64, String) -> Void else {
3434
throw DecodingError.dataCorruptedError(
3535
in: container,
3636
debugDescription: "missing userInfo for Channel handler. This is a Tauri issue"
@@ -54,12 +54,12 @@ public class Channel: Decodable {
5454
}
5555

5656
public func send(_ data: JsonValue) {
57-
handler(serialize(data))
57+
handler(id, serialize(data))
5858
}
5959

6060
public func send<T: Encodable>(_ data: T) throws {
6161
let json = try JSONEncoder().encode(data)
62-
handler(String(decoding: json, as: UTF8.self))
62+
handler(id, String(decoding: json, as: UTF8.self))
6363
}
6464

6565
}

0 commit comments

Comments
 (0)