如何取消特定的重复 UILocalNotification?
How to cancel specific repeated UILocalNotification?
我每天用 repeatInterval = 安排 UILocalNotification,但我想取消特定的通知,例如后天的通知。我可以这样做吗?
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [[NSDate date] dateByAddingTimeInterval:100];
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
现在列出您添加的所有通知。
-(void)localNotifcationList{
UIApplication *app = [UIApplication sharedApplication];
NSArray *eventArray = [app scheduledLocalNotifications];
for (int i=0; i<[eventArray count]; i++)
{
UILocalNotification* yourEventSequence = [eventArray objectAtIndex:i];
NSDictionary *userInfoCurrent = yourEventSequence.userInfo;
NSString *uid=[NSString stringWithFormat:@"%@",[userInfoCurrent valueForKey:@"uid"]];
//Based on your userinfo cancel particular notification.
// You can also compare fire date here
}
我希望这段代码能起作用。
Can i do that
没有。如果将其配置为每日重复通知,则您无法神奇地从中删除一次重复。您将不得不取消整个通知并重新安排后天开始。
我每天用 repeatInterval = 安排 UILocalNotification,但我想取消特定的通知,例如后天的通知。我可以这样做吗?
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [[NSDate date] dateByAddingTimeInterval:100];
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
现在列出您添加的所有通知。
-(void)localNotifcationList{
UIApplication *app = [UIApplication sharedApplication];
NSArray *eventArray = [app scheduledLocalNotifications];
for (int i=0; i<[eventArray count]; i++)
{
UILocalNotification* yourEventSequence = [eventArray objectAtIndex:i];
NSDictionary *userInfoCurrent = yourEventSequence.userInfo;
NSString *uid=[NSString stringWithFormat:@"%@",[userInfoCurrent valueForKey:@"uid"]];
//Based on your userinfo cancel particular notification.
// You can also compare fire date here
}
我希望这段代码能起作用。
Can i do that
没有。如果将其配置为每日重复通知,则您无法神奇地从中删除一次重复。您将不得不取消整个通知并重新安排后天开始。