fix ios dates

pull/340/head
Lucas Nogueira 2 years ago
parent 8b4b44720e
commit d8013e6ba4
No known key found for this signature in database
GPG Key ID: 7C32FCA95C8C95D7

@ -134,8 +134,11 @@ func handleScheduledNotification(_ invoke: Invoke, _ schedule: JSObject) throws
let payload = schedule["data"] as? JSObject ?? [:]
switch kind {
case "At":
let date = payload["at"] as? String ?? ""
let dateFormatter = ISO8601DateFormatter()
let date = payload["date"] as? String ?? ""
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
if let at = dateFormatter.date(from: date) {
let repeats = payload["repeats"] as? Bool ?? false
@ -157,7 +160,7 @@ func handleScheduledNotification(_ invoke: Invoke, _ schedule: JSObject) throws
timeInterval: dateInterval.duration, repeats: repeats)
} else {
invoke.reject("could not parse `at` date")
invoke.reject("could not parse `at` date \(date)")
}
case "Interval":
let dateComponents = getDateComponents(payload)

@ -40,10 +40,6 @@ func showNotification(invoke: Invoke, notification: JSObject)
do {
if let schedule = notification["schedule"] as? JSObject {
try trigger = handleScheduledNotification(invoke, schedule)
} else {
let match = Calendar.current.dateComponents(
[.timeZone, .year, .month, .day, .hour, .minute], from: Date())
trigger = UNCalendarNotificationTrigger(dateMatching: match, repeats: false)
}
} catch {
throw ShowNotificationError.create(error)

Loading…
Cancel
Save