fix(ios): decoding with default value is not supported (#1236)

This commit is contained in:
Lucas Fernandes Nogueira
2024-04-22 23:35:47 -03:00
committed by GitHub
parent faa89850d0
commit 326df68839
5 changed files with 68 additions and 49 deletions
@@ -40,7 +40,7 @@ func makeActions(_ actions: [Action]) -> [UNNotificationAction] {
for action in actions {
var newAction: UNNotificationAction
if action.input {
if action.input ?? false {
if action.inputButtonTitle != nil {
newAction = UNTextInputNotificationAction(
identifier: action.id,
@@ -66,30 +66,30 @@ func makeActions(_ actions: [Action]) -> [UNNotificationAction] {
}
func makeActionOptions(_ action: Action) -> UNNotificationActionOptions {
if action.foreground {
if action.foreground ?? false {
return .foreground
}
if action.destructive {
if action.destructive ?? false {
return .destructive
}
if action.requiresAuthentication {
if action.requiresAuthentication ?? false {
return .authenticationRequired
}
return UNNotificationActionOptions(rawValue: 0)
}
func makeCategoryOptions(_ type: ActionType) -> UNNotificationCategoryOptions {
if type.customDismissAction {
if type.customDismissAction ?? false {
return .customDismissAction
}
if type.allowInCarPlay {
if type.allowInCarPlay ?? false {
return .allowInCarPlay
}
if type.hiddenPreviewsShowTitle {
if type.hiddenPreviewsShowTitle ?? false {
return .hiddenPreviewsShowTitle
}
if type.hiddenPreviewsShowSubtitle {
if type.hiddenPreviewsShowSubtitle ?? false {
return .hiddenPreviewsShowSubtitle
}
@@ -64,9 +64,9 @@ struct NotificationAttachment: Codable {
struct Notification: Decodable {
let id: Int
var title: String = ""
var body: String = ""
var extra: [String: String] = [:]
var title: String
var body: String
var extra: [String: String]?
let schedule: NotificationSchedule?
let attachments: [NotificationAttachment]?
let sound: String?
@@ -126,10 +126,10 @@ struct CancelArgs: Decodable {
struct Action: Decodable {
let id: String
let title: String
var requiresAuthentication: Bool = false
var foreground: Bool = false
var destructive: Bool = false
var input: Bool = false
var requiresAuthentication: Bool?
var foreground: Bool?
var destructive: Bool?
var input: Bool?
let inputButtonTitle: String?
let inputPlaceholder: String?
}
@@ -138,10 +138,10 @@ struct ActionType: Decodable {
let id: String
let actions: [Action]
let hiddenPreviewsBodyPlaceholder: String?
var customDismissAction = false
var allowInCarPlay = false
var hiddenPreviewsShowTitle = false
var hiddenPreviewsShowSubtitle = false
var customDismissAction: Bool?
var allowInCarPlay: Bool?
var hiddenPreviewsShowTitle: Bool?
var hiddenPreviewsShowSubtitle: Bool?
let hiddenBodyPlaceholder: String?
}