Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't create reminder calendar in iOS

I'm trying to create a reminder calendar so I can add and delete reminders. It is actually working well on the devices I use (iPhone 5/4S/4) but on certain client devices which are still iPhones - I'm getting this error below about the account not supporting reminders.

Here is the workflow:

* Init the event store.
* Request permission (check its granted for Reminder types) (iOS6+) for lower we just init.
* Create a new calendar, local storage, type = Reminder
* Save calendar to get its Identifier.

Works most of the time, this appears on some devices -

Error Domain=EKErrorDomain Code=24 “That account does not support reminders.” 

Permissions are granted and checked under Settings, Privacy, Reminders. I can't find anything in the docs about the conditions under which you'd get this error.

Thanks!

like image 904
typemismatch Avatar asked Oct 25 '12 17:10

typemismatch


2 Answers

Not sure if you still need this but here is what i ran into.

First of all i'm pretty sure that reminders cannot be set on a calendar with a local source. I kept getting the "That account does not support reminders". Even after setting all non read only properties on the calendar before committing to the event store it still didn't work. The source needs to be calDav. Then I tried Devfly's response and it didn't work either but for a different reason. It kept fetching my gmail calendar which does not allow setting reminders (i think its actually read only for events and reminders). So i used the following code to get the actual iCloud source

    for (EKSource *source in sources) {
        NSLog(@"source %@",source.title);
        if (source.sourceType ==  EKSourceTypeCalDAV && [source.title isEqualToString:@"iCloud"]) {
            localSource = source;
            break;
        }
    }

This setting this source on my new reminders calendar worked for me. hope it helps someone

like image 173
Walter Martin Vargas-Pena Avatar answered Sep 23 '22 17:09

Walter Martin Vargas-Pena


First, just a check: you are creating a "new calendar" (a whole calendar), not just a "new reminder", right?

Second: are you using iOS6? Reminders are available (in EventKit) only starting from iOS6: link

As commented by Jesse Rusak, this happens because you are probably creating the new calendar inside an account/source that doesn't support reminders. How do you create the new calendar? Do you set the source property?

the first thing you can try, is to loop all sources until you find a suitable one. EKSourceTypeLocal supports reminders. iCal too. Here a list of EKSourceType

typedef enum {
   EKSourceTypeLocal,
   EKSourceTypeExchange,
   EKSourceTypeCalDAV,
   EKSourceTypeMobileMe,
   EKSourceTypeSubscribed,
   EKSourceTypeBirthdays
} EKSourceType;

Find a suitable one:

// find local source for example
EKSource *localSource = nil;
for (EKSource *source in store.sources)
{
    if (source.sourceType == EKSourceTypeLocal)  // or another source type that supports
    {
        localSource = source;
        break;
    }
}

Then, create the new calendar setting the right source

EKCalendar *cal;
if (identifier == nil)
{
    cal = [EKCalendar calendarForEntityType:EKEntityTypeReminder eventStore:store];
    cal.title = @"Demo calendar";
    cal.source = localSource;
    [store saveCalendar:cal commit:YES error:nil];
}

Try and let me know

like image 31
LombaX Avatar answered Sep 22 '22 17:09

LombaX