我添加了一分钟重复间隔的UILocalNotification。 如何将其删除?如何删除UILocalNotification重复间隔?
0
A
回答
0
- (BOOL)scheduleNotificationOn:(NSDate*) fireDate
text:(NSString*) alertText
action:(NSString*) alertAction
sound:(NSString*) soundfileName
launchImage:(NSString*) launchImage
andInfo:(NSDictionary*) userInfo
{
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = fireDate;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = alertText;
localNotification.alertAction = alertAction;
localNotification.soundName = soundfileName != nil ? soundfileName : UILocalNotificationDefaultSoundName;
localNotification.alertLaunchImage = launchImage;
localNotification.userInfo = userInfo;
for (UILocalNotification *notification in [self allLocalNotifications]) {
if ([notification.fireDate timeIntervalSinceDate:localNotification.fireDate] == 0 &&
[notification.alertBody isEqualToString:localNotification.alertBody]
) {
return NO;
}
}
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[localNotification release];
return YES;
}
- (NSArray *)allLocalNotifications
{
return [[UIApplication sharedApplication] scheduledLocalNotifications];
}
- (void)cancelLocalNotification:(UILocalNotification *)notification
{
[[UIApplication sharedApplication] cancelLocalNotification:notification];
}
- (void)cancelAllLocalNotifications
{
[[UIApplication sharedApplication] cancelAllLocalNotifications];
}
你应该做的唯一标识符删除通知,如alertBody .. 然后
- (void)cancelLocalNotificationByAlertBody:(NSString *)alertBody
{
for (UILocalNotification *notification in [self allLocalNotifications]) {
if ([notification.alertBody isEqual:alertBodyString]) {
[self cancelLocalNotification:notification];
break;
}
}
}
1
[[UIApplication sharedApplication] cancelAllLocalNotifications];
只是复制方法didLaunchWithOptions
或viewDidLoad
甚至在上您的下一个UILocalNotification
代码。
0
尝试用
notification.repeatInterval = NSCalendarUnit(rawValue: 0)
此代码是斯威夫特。在objective-c中尝试使用相同的东西。
相关问题
- 1. 自定义UILocalNotification重复时间间隔
- 2. UILocalNotification的自定义重复间隔
- 3. 如何重复UILocalNotification声音
- 4. UILocalNotification重复
- 5. 删除重复文本之间的间隔
- 6. PHP删除重复空间
- 7. 删除与间隔
- 8. UILocalNotification重复声音
- 9. 如何删除重复项?
- 10. 如何删除重复?
- 11. 如何取消特定的重复UILocalNotification?
- 12. 如何从iPad中删除应用程序时删除UILocalNotification applicationIconBadgeNumber?
- 13. 删除重复
- 14. 删除重复
- 15. 删除“重复”
- 16. 删除重复
- 17. 删除重复
- 18. 删除重复
- 19. 删除重复
- 20. 我可以自定义UILocalNotification重复间隔(即仅限工作日吗?)
- 21. 删除间隔表的表
- 22. 在mysql中删除时间戳间隔小于5秒的重复行
- 23. 删除staging.rb和production.rb之间的重复
- 24. 如何使用间隔时间/ settimeout从服务器node.js删除/删除数据?
- 25. 以间隔重复功能?
- 26. 删除重复表
- 27. F#删除重复
- 28. 删除重复行
- 29. 删除重复项
- 30. 删除重复2000