1

내 앱의 경우 주말에 알림을 보내지 않습니다. 그래서 내 생각은 금요일에 특정 시간에 모든 알림을 취소했다, 나는 통지 특정 시간에 모든 알림 취소

(UILocalNotifications)

일정 그래서 예를 들어 내 경보이 코드를 가지고처럼 작업을 예약하여이 작업을 수행하고 싶습니다 :

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]; 

같은 방법으로 모든 알림을 취소 할 수있는 방법이 있습니까? 아니면 Apple에서 허용하지 않습니까?

답변

0

당신은 당신이 scheduledLocalNotifications을 사용할 수 있습니다, 방법

[[UIApplication sharedApplication] cancelAllLocalNotifications]; 

당신이 그들을 통해 이동하려면

모든 지역 알림을 취소하고, 어쩌면 가장 중요한 알림을 게시 할 수 있습니다.

1

당신은 함께 로컬 통지를 취소 할 수 있습니다

[[UIApplication sharedApplication] cancelLocalNotification:notification]; 

당신은 모든 지역 알림을 루프 필요가 주말에있는 경우이를 취소 할 것입니다. 와 그들을 통해 루프 : 주말 알림을 제거하기 위해 코드를 수행하기 위해 금요일에 응용 프로그램 실행을 보장해야 할 것이다 그러나

NSArray *notifications = [[UIApplication sharedApplication] scheduledLocalNotifications]; 
[notifications enumerateObjectsUsingBlock:^(UILocalNotification *notification, NSUInteger idx, BOOL *stop){ 
    if (/* notification.fireDate is on weekend */) { 
     [[UIApplication sharedApplication] cancelLocalNotification:notification]; 
    } 
}]; 

.

하지만 주말에있는 일정을 예약하지 않는 이유는 무엇입니까?

+0

죄송합니다. 평일에만 알림을 표시하고 싶습니다. Apple에서 알고있는 한 최대 64 개의 알림이 있기 때문에 매일 일정을 잡을 수 없습니다. 응용 프로그램은 금요일에 실행됩니다 (우리 사업을위한 응용 프로그램입니다). 특정 시간에 알림을 예약하는 것처럼 cancelLocalNotification 함수를 사용하여 특정 시간에 나가기를 원합니다. – user1839995

+0

앱에 취소 할 알림이있는 경우 1 시간마다 확인하는 앱이있는 것이 어떨까요? 주말에 알림을 예약 할 수없는 이유는 아직 많이 알지 못합니다. – mattjgalloway