How can I set the ID for an Event using Expo-Calendars' createEventAsync?

37 views Asked by At

I'm creating events using the createEventAsync function from Expo-Calendars. I'm trying to set the ID of the event to match the internal ID of the event that I create in my database. That way, when searching for an event on the user's device (in order to apply an update for example), I can call getEventAsync and use the ID to find that particular event.

Currently I'm searching for all of the events on the device and filtering through them until all of my database ID matches the ID that I add onto the end of the notes section so I can identify it. Furthermore I have to keep track of start and end times of the event in order to search the correct time period on their phone. This is slow and not fullproof.

This is my current code for when I'm adding an event:

let notes = item.description + "\n\n" + item.id;

const res = await Cal.createEventAsync(calendarID, {
  id: item.id,
  endDate: getAppointementDate(endDate),
  startDate: getAppointementDate(startDate),
  title: item.name,
  notes: notes,
  location: item.location,
  allDay: item.allDay,
});

As shown, I set the id, but it just ignores it and creates its own. My ID is the correct format being a uuidv4. The one that appears in notes (which is the one from my DB) doesn't appear as the id.

Docs say that I can use the Event object to set data. ID is one of the items in that object, but is not being set clearly.

enter image description here

Any suggestions on how to get around this?

0

There are 0 answers