我添加了一分鐘重複間隔的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. iphone UILocalNotification 3個月作爲重複時間間隔
- 4. UILocalNotification上重複每隔一秒
- 5. 如何重複UILocalNotification聲音
- 6. 刪除重複文本之間的間隔
- 7. UILocalNotification重複
- 8. PHP刪除重複空間
- 9. 刪除與間隔
- 10. 如何刪除重複
- 11. 如何刪除重複行
- 12. 如何刪除重複項?
- 13. 如何刪除重複值
- 14. 如何刪除重複?
- 15. 如何在UITableViewController單元中刪除UILocalNotification?
- 16. UILocalNotification重複聲音
- 17. 如何從間隔欄中刪除秒?
- 18. 如何取消特定的重複UILocalNotification?
- 19. 如何從iPad中刪除應用程序時刪除UILocalNotification applicationIconBadgeNumber?
- 20. 在觸發後刪除UILocalNotification
- 21. UILocalNotification添加和刪除
- 22. 刪除重複
- 23. 刪除重複
- 24. 刪除「重複」
- 25. 刪除重複
- 26. 重複刪除
- 27. 刪除重複
- 28. 刪除重複
- 29. 刪除重複
- 30. 刪除重複