Reputation: 11493
I cannot access my device's calendar using Eventkit. I am using a EKEventEditViewController to present a view for adding a calendar entry.
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEventEditViewController *eventController = [[EKEventEditViewController alloc]init];
eventController.eventStore = eventStore;
eventController.editViewDelegate = self;
...
[self presentViewController:eventController animated:YES completion:nil];
This works fine on the simulator but I get the following error message when running it on the phone (iOS6): "This app does not have access to your calendars"
Checking the privacy settings as advised doesn't show any entry at all for my app.
How to solve this and grant access?
Upvotes: 1
Views: 2698
Reputation: 841
You can request access
EKEventStore *store = [[EKEventStore alloc] init];
if([store respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
/* This code will run when uses has made his/her choice */
}];
}
You can also add a key to the plist (NSCalendarsUsageDescription) that will display a string when requesting said access.
Upvotes: 6