0

在里面AppDelegate我创建了一个UNNotificationRequest带有触发器的 23:58:58 pm(午夜)收到通知并在通知中心屏幕上看到。所以我知道它会触发

当时的应用程序在后台,但didReceive此时willPresent没有被调用。

当应用程序进入后台时会触发后台任务,但这可能发生在下午 4 点而不是午夜。

我怎样才能得到一个简单的函数在每晚 23:58:58 执行,尤其是。当应用程序在后台时?

提前致谢

[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)
                }
4

0 回答 0