Skip to content

Commit e791e3a

Browse files
lucasfernogSir-Thom
authored andcommitted
fix(notification): body should be optional on iOS (tauri-apps#1737)
1 parent 66abc07 commit e791e3a

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"notification": patch
3+
---
4+
5+
The notification body is now optional on iOS to match the other platforms.

plugins/notification/ios/Sources/Notification.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ func makeNotificationContent(_ notification: Notification) throws -> UNNotificat
3232
let content = UNMutableNotificationContent()
3333
content.title = NSString.localizedUserNotificationString(
3434
forKey: notification.title, arguments: nil)
35-
content.body = NSString.localizedUserNotificationString(
36-
forKey: notification.body,
37-
arguments: nil)
35+
if let body = notification.body {
36+
content.body = NSString.localizedUserNotificationString(
37+
forKey: body,
38+
arguments: nil)
39+
}
3840

3941
content.userInfo = [
4042
"__EXTRA__": notification.extra as Any,

plugins/notification/ios/Sources/NotificationPlugin.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct NotificationAttachment: Codable {
6565
struct Notification: Decodable {
6666
let id: Int
6767
var title: String
68-
var body: String
68+
var body: String?
6969
var extra: [String: String]?
7070
let schedule: NotificationSchedule?
7171
let attachments: [NotificationAttachment]?

0 commit comments

Comments
 (0)