的主要问题:如果我想给我的应用程序中的任务附加到期日,应该使用本地通知、警报或提醒吗?我希望他们得到通知,即使应用程序没有运行时,截止日期到了。
我找到了关于使用这的UILocalNotification教程,它说可以:
使我们能够在不运行应用程序的情况下向用户强制转换通知。
然而,它是六年前编写的,并指出这是在iOS4中引入的。我知道在5个iOS版本上有很多变化。
我还朗读,或者,我可以使用Event。然而,这似乎比UILocalNotification更复杂。
最后,我可以使用目前的日期/时间和提醒日期/时间和创建一个定时器倒计时。
所以,如果我只想给我的应用程序中的任务附加到期日(它们不需要在提醒或日历中显示),那么最好的方法是什么,为什么呢?
发布于 2016-01-08 18:39:16
我发现了下面的代码在这里块。对于如何在应用程序中创建事件,这也是一个很好的教程。
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)
https://stackoverflow.com/questions/34676669
复制相似问题