the notification so that we can retrieve it later notification.category = "TODO_CATEGORY" UIApplication.sharedApplication().scheduleLocalNotification(notification) self.setBadgeNumbers() } todoDictionary[item.UUID] = ["deadline": item.deadline, This will store NSData "title": item.title, "UUID": item.UUID] representation of todo item in dictionary with UUID as key NSUserDefaults.standardUserDefaults() This will save/overwrite todo .setObject(todoDictionary, forKey: ITEMS_KEY) item list let notification = UILocalNotification() This will create the medicine notification.alertBody = "Todo Item \"\(item.title)\" reminder notification and Is Overdue" what the text will be on the notification. notification.alertAction = "open" This is the text that is displayed after "slide to..." on the lock screen - defaults to "slide to view" self.setBadgeNumbers() This will update the on adding new item So, when Medicine reminder notification shows the user has two choices: one is to press Complete if he took the medicine and the other option is to remind him in 30 minutes and this is the function that do the reminder: func scheduleReminderforItem(item: TodoMedicineItem) { let notification = UILocalNotification() // create a new reminder notification notification.alertBody = "Medicine Intake\"\(item.title)\" Is Overdue" // text that will be displayed in the notification
the notification so that we can retrieve it later notification.category = "TODO_CATEGORY" UIApplication.sharedApplication().scheduleLocalNotification(notification) self.setBadgeNumbers() } todoDictionary[item.UUID] = ["deadline": item.deadline, "title": item.title, "UUID": item.UUID] This will store NSData representation of todo item in dictionary with UUID as key NSUserDefaults.standardUserDefaults() .setObject(todoDictionary, forKey: ITEMS_KEY) This will save/overwrite todo item list let notification = UILocalNotification() notification.alertBody = "Todo Item \"\(item.title)\" Is Overdue" This will create the medicine reminder notification and what the text will be on the notification. notification.alertAction = "open" This is the text that is displayed after "slide to..." on the lock screen - defaults to "slide to view" self.setBadgeNumbers() This will update the on adding new item So, when Medicine reminder notification shows the user has two choices: one is to press Complete if he took the medicine and the other option is to remind him in 30 minutes and this is the function that do the reminder: func scheduleReminderforItem(item: TodoMedicineItem) { let notification = UILocalNotification() // create a new reminder notification notification.alertBody = "Medicine Intake\"\(item.title)\" Is Overdue" // text that will be displayed in the notification