将 UI 通知发送静音一段时间



每当用户接近我的客户端之一时,即使在后台,我的应用程序都会通知(使用 UILocalNotification )用户。

我有一个静音按钮,当用户单击时,会弹出一个操作表,并询问他想将应用程序静音多长时间(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
  }    

注意:刚刚编写了步骤,请根据语言进行更改。

相关内容

最新更新