nullable strings

pull/340/head
Lucas Nogueira 2 years ago
parent f776c742b4
commit bf6e0b0ca7
No known key found for this signature in database
GPG Key ID: FFEA6C72E73482F1

@ -197,19 +197,19 @@ class Notification {
val notification = Notification() val notification = Notification()
notification.source = jsonObject.toString() notification.source = jsonObject.toString()
notification.id = jsonObject.getInteger("id") ?: throw Exception("Missing notification identifier") notification.id = jsonObject.getInteger("id") ?: throw Exception("Missing notification identifier")
notification.body = jsonObject.getString("body") notification.body = jsonObject.getString("body", null)
notification.largeBody = jsonObject.getString("largeBody") notification.largeBody = jsonObject.getString("largeBody", null)
notification.summary = jsonObject.getString("summary") notification.summary = jsonObject.getString("summary", null)
notification.actionTypeId = jsonObject.getString("actionTypeId") notification.actionTypeId = jsonObject.getString("actionTypeId", null)
notification.group = jsonObject.getString("group") notification.group = jsonObject.getString("group", null)
notification.setSound(jsonObject.getString("sound")) notification.setSound(jsonObject.getString("sound", null))
notification.title = jsonObject.getString("title") notification.title = jsonObject.getString("title", null)
notification.setSmallIcon(jsonObject.getString("icon")) notification.setSmallIcon(jsonObject.getString("icon", null))
notification.setLargeIcon(jsonObject.getString("largeIcon")) notification.setLargeIcon(jsonObject.getString("largeIcon", null))
notification.iconColor = jsonObject.getString("iconColor") notification.iconColor = jsonObject.getString("iconColor", null)
notification.attachments = NotificationAttachment.getAttachments(jsonObject) notification.attachments = NotificationAttachment.getAttachments(jsonObject)
notification.isGroupSummary = jsonObject.getBoolean("groupSummary", false) notification.isGroupSummary = jsonObject.getBoolean("groupSummary", false)
notification.channelId = jsonObject.getString("channelId") notification.channelId = jsonObject.getString("channelId", null)
val schedule = jsonObject.getJSObject("schedule") val schedule = jsonObject.getJSObject("schedule")
if (schedule != null) { if (schedule != null) {
notification.schedule = NotificationSchedule(schedule) notification.schedule = NotificationSchedule(schedule)
@ -260,7 +260,7 @@ class Notification {
val schedule = notification.schedule val schedule = notification.schedule
if (schedule != null) { if (schedule != null) {
val jsSchedule = JSObject() val jsSchedule = JSObject()
jsSchedule.put("kind", schedule.scheduleObj.getString("kind")) jsSchedule.put("kind", schedule.scheduleObj.getString("kind", null))
jsSchedule.put("data", schedule.scheduleObj.getJSObject("data")) jsSchedule.put("data", schedule.scheduleObj.getJSObject("data"))
jsNotification.put("schedule", jsSchedule) jsNotification.put("schedule", jsSchedule)
} }

@ -231,7 +231,7 @@ class TauriNotificationManager(
) { ) {
return return
} }
notificationManager.notify(notification.id ?: 0, buildNotification) notificationManager.notify(notification.id, buildNotification)
} }
} }

Loading…
Cancel
Save