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:
- Cancel all the notifications.
- 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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…