Events

Create a new event with the EKEventStore.Instance.SaveEvent() method of the EKEventStore class.

You can set some of the details include:

  • The event’s title with the title .

  • The event’s start and end dates with the startDate and endDate parameters.+

  • The alarm associated with the event with the alarm  parameter.

  • The event’s recurrence rule, if it is a repeating event, with the recurrenceRules parameter.

To add alarm parameter to your event you need to create new ISN_AlarmDataRequest and set there dueDate or timeStamp like this for example:

ISN_AlarmDataRequest alarm = new ISN_AlarmDataRequest(System.DateTime.Now);

To add recurrenceRules parameter to your event you need to create new ISN_RecurrenceRuleRequest and set there frequency and interval also you can set endDate like this for example:

ISN_RecurrenceRuleRequest recurrenceRule = new ISN_RecurrenceRuleRequest(ISN_RecurrenceFrequencies.Monthly, 2);

Next to save event you need to call EKEventStore.Instance.SaveEvent() method:

EKEventStore.Instance.SaveEvent("Test event", System.DateTime.Now, System.DateTime.Now, alarm, recurrenceRule, (request)=>
{
    if(request.Result.IsSucceeded)
    {
       Debug.Log(Yey, It's working! ID is - " + request.Identifier);
    }
    else
    {
        Debug.Log("We have error - "+ request.Result.Error.FullMessage);
    }
});

This request will return ISN_EventKitSaveResult object that contains Identifier of created event or error. You can use this Identifier for removing this event, to do this you need to call EKEventStore.Instance.RemoveEvent() method like this:

EKEventStore.Instance.RemoveEvent(m_EventID, (request) =>
{
    if(request.IsSucceeded)
    {
        Debug.Log("We removed event!");
    }
    else
    {
        Debug.Log("We have error at removing event!");
    }
});