Setting Alarms Using Calendar.createEventAsync


#1

What is the correct format for the array of alarms in Calendar.createEventAsync?

I am using the following code to create an event on my device’s calendar. However, whenever I attempt to create an event, my program crashes. It does not crash if no alarms are included in the event.

let eventDetails = {
      title: 'Test Event',
      startDate: moment()
        .add(1, 'm')
        .toDate(),
      endDate: moment()
        .add(5, 'm')
        .toDate(),
      timeZone: Localization.timezone,
      // alarms (Array<Alarm>)

  /**** This causes the crash ****/
     alarms: [
        {
          method: Calendar.AlarmMethod.DEFAULT
        }
      ] 
    };

    console.log(eventDetails);

    try {
      let createEventAsyncRes = await Calendar.createEventAsync(
        this.state.calendarID,
        eventDetails
      );
      console.log({ createEventAsyncRes });
    } catch (error) {
      console.log(error);
    }

closed #2

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.