静音 UILocalNotifications 发送一段时间

Mute UILocalNotifications sending for a certain time

每当用户接近我客户的一家商店时,我的应用程序都会通知(使用 UILocalNotification)用户,即使在后台也是如此。

我有一个静音按钮,当用户单击该按钮时,会弹出一个 actionSheet 并询问他希望将应用静音多长时间(5 小时、24 小时、1 周或 1 个月)。

当用户选择其中一个选项时,我希望应用程序停止发送通知,直到这个时间过去。

最好的方法是什么?

非常感谢代码示例。

谢谢!

//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

  }    

注意:刚刚写的步骤,根据语言标准更改。