2012-11-13 41 views
0

我的應用程序只需在工作日觸發警報。 我的想法是安排每天的通知,但問題是,我讀了64個預定通知是您可以擁有的最大通知量,而我的通知將共有120個通知,因此無法完成。UILocalNotification:在特定日期全部取消

現在我想知道是否有辦法取消週六和週日的所有通知。

我現在使用重複通知在週末的代碼:在[UIApplication scheduledLocalNotifications]

NSDateComponents *comps = [[NSDateComponents alloc] init]; 
    [comps setHour:8]; 
    [comps setMinute:25]; 
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; 
    NSDate *fireDate = [gregorian dateFromComponents:comps]; 

    UILocalNotification *alarm = [[UILocalNotification alloc] init]; 

    alarm.fireDate = fireDate; 
    alarm.repeatInterval = NSDayCalendarUnit; 
    alarm.soundName = @"sound.aiff"; 
    alarm.alertBody = @"Message.."; 
    alarm.timeZone = [NSTimeZone defaultTimeZone]; 
    [[UIApplication sharedApplication] scheduleLocalNotification:alarm]; 
+0

您可以隨時檢查,每週一天,當你初始化日期/時間的通知。你能告訴我你的代碼在哪裏設置你的通知? –

+0

@anatoliy_v請看我第一次更新的帖子,提前致謝。 – user1771336

回答

0

瞧,你都通知調度。

這是一個數組UILocalNotification

做一個循環這個數組,並期待在通知之日起fireDate,並做到:

[UIApplication cancelLocalNotification:theNotificationToDelete]; 
+0

感謝您的回覆,但我不知道您的意思。我的通知正常,但每天都會重複,我希望它在星期四和星期天全部取消。 – user1771336

+0

您是否預先安排了每天的所有通知? – malinois

+0

我剛剛創建了24個通知,並將重複設置爲每日,因爲由於Apple的限制,我無法安排120個通知。 – user1771336