TheBearF8
TheBearF8

Reputation: 395

didReceive and willPresent not called while app is in the background

inside AppDelegate I create a UNNotificationRequest with a trigger for 23:58:58pm (midnight) The notification is received and is seen on the notification center screen. so I know it triggers

The app at that time is in the background, but didReceive and willPresent are NOT called at this time.

Having a background task triggers when the app goes into the background, but this may occur at 4pm not midnight.

How can I get a simple function to execute at 23:58:58 each night, esp. when the app is in the background?

Thanks in advance

[DateComponents(hour: 23, minute: 58, second: 58)].forEach {
                    let trigger = UNCalendarNotificationTrigger(dateMatching: $0, repeats: true)
                    let request = UNNotificationRequest(identifier: identifier, content: content, trigger: trigger)
                    center.add(request)
                }

Upvotes: 0

Views: 199

Answers (0)

Related Questions