1

I create an alarm app , which have 3 times (morning,afternoon and evening), by implementation a local notification, and its work and the alarm fire in the same time which I put.

but I create in interface builder a view with 3 button for the same Timing (morning, afternoon and evening) to give the user the ability to disable and enable any kind of notification he want to receive.

I read some of solution to delete the local notification here https://stackoverflow.com/a/6341476/2209611

and here https://stackoverflow.com/a/6495321/2209611

but both of them will delete all of local notification.

How can I customize the local notification to represent a certain time, such as the (morning or evening) when i fire date ?

and how can I disable only one of categories (not delete it ) or enable it again if the user want to reactive it?

Community
  • 1
  • 1
aqeel
  • 153
  • 1
  • 2
  • 11
  • What's the effective difference between enabling/disabling and deleting/recreating? I suspect you will probably have to outright delete the notification and recreate it again later. You can easily store values for the time and such for when the user re-enables (recreates) the alarm. – Doc Jan 06 '14 at 19:17
  • @Doc because i have 3 kind of notification (morning,afternoon and evening) and my be the user want to delete only on of them not of all, and i don't know how to make a categories for local notification when create a local notifications , i pull the dates from DB then fire it to local notification – aqeel Jan 06 '14 at 19:27
  • Maybe I could retrieve a certain category of DB ,then fire it, but I thought that perhaps there is an easier way. – aqeel Jan 06 '14 at 19:38
  • You can delete an individual notification (the first linked answer you gave shows how). Just keep a reference of which notification belongs to which alarm. When the user disables a given alarm, delete the respective notification. If (s)he re-enables it, recreate the notification. – Doc Jan 06 '14 at 20:06
  • @Doc (in the first link) i don't know what is the (uid) ? what is the code which i should put to store the (uid) ? and what is (uidtodelete) ? – aqeel Jan 06 '14 at 20:23
  • In the example, when creating the local notification you store an identifier (which he names UID) in the notification's userInfo. He can then later pull this identifier from the userInfo and compare it to to a desired identifier (uidToDelete). For example, you have three alarms. In the morning alarm's userInfo, you store "morning" in a UID key. Later, the user wishes to disable the morning alarm. You get the list of local notifications and iterate through them, searching for the one who's UID key is "morning". You then delete that notification. – Doc Jan 06 '14 at 20:39
  • @Doc good , now i put all the necessary code , like you said , and every thing is working fine , thank you very much Doc :) – aqeel Jan 07 '14 at 22:16

0 Answers0