gpt4 book ai didi

ios - 如何在特定日期前 2 天触发 UserNotifications

转载 作者:行者123 更新时间:2023-11-28 06:13:27 25 4
gpt4 key购买 nike

如何在特定日期前 2 天触发 UserNotifications

我之前尝试过 UserNotification,但我知道我基于时间间隔,但我不知道如何根据日期触发此通知。有人可以帮我吗。谢谢。:)

最佳答案

我弄明白了,谢谢你的帮助。埃尔番茄

func prepareNotification() {

let content = UNMutableNotificationContent()
content.title = "Eva Reminder"
content.body = "2 Days Left Before Your Period Days."
content.sound = UNNotificationSound.default()

var components = DateComponents()
components.day = numberOfDaySelected - 2
components.hour = 7
components.minute = 0
let trigger = UNCalendarNotificationTrigger(dateMatching: components, repeats: true)
let request = UNNotificationRequest(identifier: "eva.notification", content: content, trigger: trigger)

UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
}

关于ios - 如何在特定日期前 2 天触发 UserNotifications,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45808150/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com