Skip to content

Commit 3781a37

Browse files
committed
Bugfix: send notifications even if not all characters are supported
1 parent 94579bf commit 3781a37

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

InfiniLink/BLE/BLEWriteManager.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,15 @@ struct BLEWriteManager {
5252
let title = transliterationEnabled ? notif.title.asciiSafe : notif.title
5353
let body = transliterationEnabled ? notif.subtitle.asciiSafe : notif.subtitle
5454

55-
// Convert strings to ASCII
56-
let titleData = (" " + title + "\0").data(using: .ascii)
57-
let bodyData = (body + "\0").data(using: .ascii)
55+
let titleData = (" " + title + "\0").data(using: .utf8)
56+
let bodyData = (body + "\0").data(using: .utf8)
5857

5958
// Log if there was a failure when converting
6059
if titleData == nil {
61-
log("Failed to convert \(notif.title) to ASCII data", caller: "BLEWriteManager", target: .ble)
60+
log("Failed to convert \(notif.title) to UTF-8 data", caller: "BLEWriteManager", target: .ble)
6261
}
6362
if bodyData == nil {
64-
log("Failed to convert \(notif.subtitle) to ASCII data", caller: "BLEWriteManager", target: .ble)
63+
log("Failed to convert \(notif.subtitle) to UTF-8 data", caller: "BLEWriteManager", target: .ble)
6564
}
6665

6766
// If either the strings couldn't be converted, don't send the notification

0 commit comments

Comments
 (0)