1

Predicate call to calendar daemon failed: Error Domain=EKCADErrorDomain Code=1013 "The operation couldn’t be completed. (EKCADErrorDomain error 1013.)"

I am trying to fetch reminders from default app.

if([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {
        // need user permission for iOS 6 and later
        [eventStore requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) {
            if (granted) {
                //---- codes here when user allow your app to access theirs' calendar.
                [self performCalendarActivity:eventStore];
            }
            else {
                //----- codes here when user NOT allow your app to access the calendar.
            }
        }];
    }

---- Fetching the reminder for the date-----

-(void)performCalendarActivity:(EKEventStore*)evtStore
{
    self.eventsList = [[NSMutableArray alloc] initWithArray:0];
    int seconds_in_day = 60*60*24;// 1 day = 60*60*24 seconds = 86400 seconds
    NSDate *endDate = [startDate dateByAddingTimeInterval:seconds_in_day];

    // use Dictionary for remove duplicates produced by events covered more one year segment
    NSMutableDictionary *eventsDict = [NSMutableDictionary dictionaryWithCapacity:1024];
    NSDate* currentStart = [NSDate dateWithTimeInterval:0 sinceDate:startDate];
    NSDate* currentFinish = [NSDate dateWithTimeInterval:seconds_in_day sinceDate:currentStart];

    if ([currentFinish compare:endDate] == NSOrderedDescending) {
        currentFinish = [NSDate dateWithTimeInterval:0 sinceDate:endDate];
    }
    NSMutableArray *events = [NSMutableArray arrayWithObjects: nil];

    NSArray *calendars = [eventStore
                          calendarsForEntityType:EKEntityTypeReminder];

    NSPredicate *predicate = [eventStore predicateForRemindersInCalendars:calendars];
   //NSPredicate *predicate = [eventStore predicateForIncompleteRemindersWithDueDateStarting:startDate ending:currentFinish calendars:calendars];
    [eventStore fetchRemindersMatchingPredicate:predicate completion:^(NSArray *ekReminders){
        [events addObjectsFromArray:ekReminders];
    }];
}

I am getting this error:- Predicate call to calendar daemon failed: Error Domain=EKCADErrorDomain Code=1013 "The operation couldn’t be completed. (EKCADErrorDomain error 1013.)"

Please help.

HDdeveloper
  • 4,396
  • 6
  • 40
  • 65
  • Possible duplicate of [defaultCalendarForNewEvents failed](http://stackoverflow.com/questions/12454324/defaultcalendarfornewevents-failed) – jrc Oct 02 '15 at 15:36

1 Answers1

2

The warning is because the user didn't give the permission for accessing the reminder.

Quick Fix:

  1. Goto Settings
  2. Select Privacy
  3. Select Reminders
  4. Choose your application and allow access of "Reminders" to ON.
HDdeveloper
  • 4,396
  • 6
  • 40
  • 65
  • 1
    I solved that problem.It's because my EKEntityType is wrong.I set the type EKEntityTypeReminder,but I read the EKEvent.So it complain. your method is right.thank you. – frank Mar 26 '14 at 12:36
  • @frank please if possible to give me your changes demo because. i use this demo - http://www.appcoda.com/ios-event-kit-programming-tutorial/ but i will gives same as your error i try but not solve it. – Gami Nilesh Oct 30 '15 at 04:50