Swetha
Swetha

Reputation: 95

is it possible to change the default alarm timings in icalendar using eventkit?

I used the following code to display a calendar using EVENTKIT

    - (BOOL)createEvent:(NSString *)title 
                 at:(NSString *)location 
           starting:(NSDate *)startDate 
             ending:(NSDate *)endDate 
           withBody:(NSString *)body 

{

    eventStore = [[EKEventStore alloc] init];

    EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
    event.title     = title;
    event.location  = location;
    event.startDate = startDate;
    event.endDate   = endDate;
    event.notes     = body;

    [event setCalendar:[eventStore defaultCalendarForNewEvents]];

    EKEventEditViewController *eventViewController = [[EKEventEditViewController alloc] init];
    eventViewController.event = event;
    eventViewController.eventStore = eventStore;
    //eventViewController.editViewDelegate = self;

    [self presentModalViewController:eventViewController animated:YES];

    return TRUE;
}

When i call this above function , an eventkit view controller is displayed. When i click the the alert button in that, i will get the default alert timing as like below

Event Alert

I want the event alert timing in whatever way i wish like 1 day before,2 days before upto 30 days before.

Can anyone please tell me how to do this Many Thanks in advance

Upvotes: 4

Views: 484

Answers (1)

BadPirate
BadPirate

Reputation: 26177

You'll want to create an EKAlarm, and add that alarm to your event. For instance, for an alarm that occurs 15 min before:

    EKAlarm *alarm = [EKAlarm alarmWithRelativeOffset:-900]; // 15 min alarm
    [event addAlarm:alarm];

Upvotes: 3

Related Questions