1

My app notifies (using UILocalNotification) the user every time he approaches one of the stores of my client, even in the background.

I have a mute button that when the user clicks on, an actionSheet pops and asks the him for how long he would like to mute the app (5h, 24h, 1 week or 1 month).

When the user chooses one of the options, I want the app to stop sending notifications until this time will pass.

What is the best way to do this?

I'll really appreciate a code example.

Thanks!

Jagat Dave
  • 1,643
  • 3
  • 23
  • 30
FS.O
  • 403
  • 6
  • 24
  • What have you tried? Since your app has to generate the notifications, why not calculate the expiration of the mute period and store it. Before generating a new notification, check the current date against the stored date. – Avi Feb 09 '16 at 10:18
  • @Avi can you give me a code example for this? Maybe I'll understand it more – FS.O Feb 09 '16 at 10:19
  • Which part is hard? storing the date for future comparison? Generating the date? Comparing the date? You haven't even given us any code to look at. – Avi Feb 09 '16 at 10:30
  • @Avi Thanks for the answer I understood what you mean now. But I have also an option in the actionSheet that the notifications won't be sent until the user unmute manually from the app. How can I do that? – FS.O Feb 09 '16 at 10:35

1 Answers1

0
//fire local notification 

    NSDate * storedDate // Store your date when setting the mute 
    int tillHoursForMute // hours for mute

    muteDate  = <storedDate+tillHoursForMute> //concatenate the hours into date
   if ([muteDate compare:firingDate] == NSOrderedDescending && [muteDate compare:firingDate] == NSOrderedAscending) {
    //fire Notification        

   } else {
      //Mute time

  }    

Note : Just written the steps, Change it as per language stands.

Kumar KL
  • 15,315
  • 9
  • 38
  • 60