【问题标题】:how can I use repeatinterval every 10 minutes ??如何每 10 分钟使用一次重复间隔?
【发布时间】:2011-08-11 10:53:16
【问题描述】:

有没有办法设置本地通知repeatinterval每10分钟一次。

我尝试使用

localnotification.repeatInterval = NSMinuteCalendarUnit*3;

localNotif.repeatInterval = 640;

它不起作用。

所以请你指导我。 :)

【问题讨论】:

  • 请查看答案并将其标记为答案。

标签: iphone objective-c ios uilocalnotification


【解决方案1】:

正如 Mundi 所说,repeatInterval 必须是 NSCalendarUnit,并且只能包含:NSWeekCalendarUnitNSMonthCalendarUnitNSDayCalendarUnitNSHourCalendarUnit、..

所以每 10 分钟收到一次通知。使用 6 个每小时重复一次的通知,并在通知之间设置 10 分钟。

【讨论】:

    【解决方案2】:

    我认为你不能这样做。

    如果您想参考那个问题,我之前曾问过类似的问题。

    这是链接

    How to set Local Notification repeat interval to custom time interval?

    希望对你有所帮助。

    【讨论】:

      【解决方案3】:

      NSTimeInterval 以秒为单位,因此十分钟将是 600.0,而不是 640

      NSMinutesCalenderUnit 具有任意定义的值,并且不包含每分钟的秒数。

      您是否检查过您是否使用scheduleLocalNotification: 正确安排了通知,并且您是否在您的 AppDelegate 中实施了application:didReceiveLocalNotification:

      【讨论】:

        【解决方案4】:

        您是否也必须取消通知?像这样

        [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

        【讨论】:

          猜你喜欢
          • 2015-08-31
          • 2012-02-08
          • 1970-01-01
          • 1970-01-01
          • 2015-10-12
          • 2016-10-18
          • 2023-03-16
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多