每x分钟检查一次背景情况,如果是,则发送通知

时间:2013-10-12 14:50:12

标签: iphone ios objective-c notifications uilocalnotification

我一直在寻找几个小时的解决方案。我知道如何使用本地通知。我发现可以重复显示本地通知,但通知正文和图标徽章编号应始终相同。我想要做的是:即使应用程序没有运行,也要反复检查条件,如果条件为真,请向通知中心发送通知,向应用程序的图标徽标显示一个数字。要显示的数字来自数据库。

有人知道如何处理吗?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

那么你可以这样做,使用nstimer,然后每隔几分钟运行一次,然后内部计时器选择器根据该帖子后通知写你的条件以便检查。

   [NSTimer scheduledTimerWithTimeInterval:1
  target:self select:@selector(sendnotification:)    userInfo:nil repeats:YES];

   -(void)sendnotification:(Nstimer*)timer
   {
   //post notification here
    }
相关问题