UILocalNotification - repeatInterval reset (no repeat)

后端 未结 1 612
一整个雨季
一整个雨季 2020-12-21 16:50

Overview

  • I am creating a notification based on an existing instance of UILocalNotification
  • Existing instance has r
相关标签:
1条回答
  • 2020-12-21 17:34

    Taken from Apple documentation:

    If you assign an calendar unit such as weekly (NSWeekCalendarUnit) or yearly (NSYearCalendarUnit), the system reschedules the notification for delivery at the specified interval. The default value is 0, which means don't repeat.

    I assume you want to cancel the notification with the repeating interval, you can do that in two ways:

    1. Cancel all the notifications.
    2. Cancel only that notification.

    The first option is easy, use:

    cancelAllLocalNotifications
    

    In your app delegate.

    The second one requires more work. You need to go through the pending notifications (use scheduledLocalNotifications) and cancel the notification.

    In order to know which notifications is going to be canceled you can use the userInfo property when you set the notification. For example set an unique ID for every notification so when you cancel that notification you simply compare that ID with all the IDs in your scheduledLocalNotifications array.

    0 讨论(0)
提交回复
热议问题