我使用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