A 2 part question: Using the SDK's view controller to add an event is working, but I would like to have it default to Alert = "At time of event" or any other of the available options; how do I do that?. Secondly, I would like to have an alert display when the event is finished. I tried adding an EKAlarm set to endDate, but no alert is fired. Can this be done when using the SDK's EKEventEditViewController?
If what I'm trying to falls in the category of customizing the EKEventEditViewController, then I think most other Qs on SO say that it is not allowed example.
Here is the code (iOS 7):
- (void)eventEditViewController:(EKEventEditViewController *)controller
didCompleteWithAction:(EKEventEditViewAction)action{
AlarmTimerTriggersTVC * __weak weakSelf = self;
// Dismiss the modal view controller
[self dismissViewControllerAnimated:YES completion:^
{
if (action != EKEventEditViewActionCanceled)
{
dispatch_async(dispatch_get_main_queue(), ^{
EKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:controller.event.endDate];
controller.event.alarms = [NSArray arrayWithObject:alarm];
// Re-fetch all events happening in the next 24 hours
weakSelf.eventsList = [self fetchEvents];
// Update the UI with the above events
[weakSelf.tableView reloadData];
});
}
}];
}
Try to save the event after setting the alarm on it
EKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:controller.event.endDate];
controller.event.alarms = [NSArray arrayWithObject:alarm];
NSError* error = nil;
[eventStore saveEvent: controller.event
span: span
error: &error];
EDIT:
For the time of the event its something like this
controller.event.alarms = [NSArray arrayWithObject:
[EKAlarm alarmWithRelativeOffset: 0]];