#import <EventKit/EventKit.h>
I can't create event in default iOS calendar.
EKEventStore *eventStore = [[EKEventStore alloc] init];
for (EKSource *source in eventStore.sources)
{
if (source.sourceType == EKSourceTypeCalDAV || source.sourceType == EKSourceTypeLocal)
{
NSLog(@"I found it");
break;
}
}
Beginning from here it couldn't return any sources. When I build and run app there are no any requests to give its access to default calendar.
All in all I get an empty array:
[eventStore.sources count]
Even when I trying to add event without creating new calendar (using
[eventStore defaultCalendarForNewEvents]
I guess there is problem in accessing EKEventStore, to check permission try following,
EKEventStore *eventStore = [[EKEventStore alloc] init];
if ([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)]){
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error)
{
NSLog(@"GRANTED: %c", granted);
for (EKSource *source in eventStore.sources)
{
if (source.sourceType == EKSourceTypeCalDAV || source.sourceType == EKSourceTypeLocal)
{
NSLog(@"I found it");
break;
}
}
}];
}
Hope it Helps you..
I have found problem:
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
// TODO
}];
I must request permission manually, thought permission set without it, I think it had fixed in iOS 7.0.2 build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With