gpt4 book ai didi

ios - iOS8-iOS9设置提醒/闹钟

转载 作者:行者123 更新时间:2023-11-28 06:51:49 29 4
gpt4 key购买 nike

主要问题:如果我想在我的应用程序中为任务附加截止日期,我应该使用本地通知、警报或提醒吗?我希望他们在截止日期到来时即使应用程序未运行也能收到通知。

我找到了 this关于使用它说可以的 UILocalNotification 的教程:

gives us the ability to cast notifications to a user without running the application

然而,它是六年前写的,并且还声明这是在 iOS4 中引入的。我知道 5 个 iOS 版本有很多变化。

我也是read ,或者,我可以使用 Event Kit。然而,这似乎比 UILocalNotification 更复杂。

最后,我可能会使用当前日期/时间和提醒日期/时间和 create a timer倒计时。

因此,如果我只想将截止日期附加到我应用程序中的任务(它们不需要显示在提醒或日历中),最好的方法是什么?为什么?

最佳答案

我发现以下 block code here .这也是关于如何在应用程序中创建事件的一个很好的教程。

var notification = UILocalNotification()
notification.alertBody = "Todo Item \"\(item.title)\" Is Overdue" // text that will be displayed in the notification
notification.alertAction = "open" // text that is displayed after "slide to..." on the lock screen - defaults to "slide to view"
notification.fireDate = item.deadline // todo item due date (when notification will be fired)
notification.soundName = UILocalNotificationDefaultSoundName // play default sound
notification.userInfo = ["UUID": item.UUID, ] // assign a unique identifier to the notification so that we can retrieve it later
notification.category = "TODO_CATEGORY"
UIApplication.sharedApplication().scheduleLocalNotification(notification)

关于ios - iOS8-iOS9设置提醒/闹钟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34676669/

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