我使用repeatInterval =每天计划UILocalNotification,但是我想取消特定的通知,例如后天的通知。我可以那样做吗?如何取消特定的重复UILocalNotification?
-1
A
回答
1
0
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
}
我希望这段代码能够正常工作。
相关问题
- 1. 取消特定的UILocalNotification
- 2. 如何取消注册/取消UILocalNotification
- 3. 如何重复UILocalNotification声音
- 4. 如何在特定日期获得UILocalNotification重复
- 5. UILocalNotification在特定的一天如星期天重复,每2周
- 6. 取消UILocalNotification
- 7. UILocalNotification重复
- 8. 如何获取UILocalNotification取消事件?
- 9. 为什么我不能取消重复的UILocalNotification?
- 10. UILocalNotification不会取消
- 11. UILocalNotification重复声音
- 12. UILocalNotification的自定义重复间隔
- 13. AlarmManager如何取消重复
- 14. 如何删除UILocalNotification重复间隔?
- 15. 如何从自定义类创建和取消唯一的UILocalNotification?
- 16. 自定义UILocalNotification重复时间间隔
- 17. UILocalNotification - 按repeatInterval复位(不重复)
- 18. 如何取消或重置特定的表单值?
- 19. 如何用特定的request_code取消特定的pendingIntent?
- 20. 在某周的某几天重复UILocalNotification
- 21. 如何获取特定子串的范围(即使重复)
- 22. 每天消防UILocalNotification,但每天在特定时间
- 23. 如何在特定时间取消PendingIntent?
- 24. 我需要停止或取消UILocalNotification
- 25. 2分钟后UILocalNotification重复提醒
- 26. VBA Excel - 如何从多个重复行中获取特定值
- 27. 如何在swift3中看到UILocalNotification后取消或删除?
- 28. 如何取消特定重复本地通知,并重新计划下周在iOS的10(SWIFT)
- 29. XMPPFramework - 获取重复消息
- 30. 取消重复请求NSURLConnection
遍历'UIApplication.shard()。scheduledLocalNotifications'中的计划通知并检查每个通知上的'fireDate'。如果'fireDate'匹配您想要取消的那个,请删除通知。 – Wes
@Wes在“scheduledNotifications”中只有一个通知。有没有未来的通知,所以我不能比较被解雇 – Gikas