diff --git a/.changes/notification-body-optional-ios.md b/.changes/notification-body-optional-ios.md new file mode 100644 index 00000000..3bcdbc75 --- /dev/null +++ b/.changes/notification-body-optional-ios.md @@ -0,0 +1,5 @@ +--- +"notification": patch +--- + +The notification body is now optional on iOS to match the other platforms. diff --git a/plugins/notification/ios/Sources/Notification.swift b/plugins/notification/ios/Sources/Notification.swift index 0f572aa9..adba05ec 100644 --- a/plugins/notification/ios/Sources/Notification.swift +++ b/plugins/notification/ios/Sources/Notification.swift @@ -32,9 +32,11 @@ func makeNotificationContent(_ notification: Notification) throws -> UNNotificat let content = UNMutableNotificationContent() content.title = NSString.localizedUserNotificationString( forKey: notification.title, arguments: nil) - content.body = NSString.localizedUserNotificationString( - forKey: notification.body, - arguments: nil) + if let body = notification.body { + content.body = NSString.localizedUserNotificationString( + forKey: body, + arguments: nil) + } content.userInfo = [ "__EXTRA__": notification.extra as Any, diff --git a/plugins/notification/ios/Sources/NotificationPlugin.swift b/plugins/notification/ios/Sources/NotificationPlugin.swift index c8974b36..9371e83d 100644 --- a/plugins/notification/ios/Sources/NotificationPlugin.swift +++ b/plugins/notification/ios/Sources/NotificationPlugin.swift @@ -65,7 +65,7 @@ struct NotificationAttachment: Codable { struct Notification: Decodable { let id: Int var title: String - var body: String + var body: String? var extra: [String: String]? let schedule: NotificationSchedule? let attachments: [NotificationAttachment]?