Search code examples
javascriptreactjsgoogle-calendar-api

What parameters are required to set Google Calender Notification time


I have to change the google calendar notification time from 30 minutes to 5 minutes.

const encodedUrl = encodeURI(
    [
      "https://www.google.com/calendar/render",
      "?action=TEMPLATE",
      `&text=${calendarEvent.title || ""}`,
      `&dates=${startDate || ""}`,
      `/${endDate || ""}`,
      `&[email protected],[email protected]`,
      // TODO: append video appointment link to description
      `&details=${`${calendarEvent.description}\n` || ""}`,
      `&location=${calendarEvent.address || ""}`,
      "&sprop=&sprop=name:"
    ].join("")
  );

With the above URL string, I can set the event title, event timing, and event location parameters except for the notification time. But now I want to update the notification time in the calendar event in the above link, Is that possible?

enter image description here


Solution

  • The Events resource from Calendar API includes a reminders property, which can be used to manage event notifications.

    Therefore, you can update the event notifications via Events: patch or Events: update by adding the reminders property to your payload.

    For example, if you were calling this API on Google Apps Script, you would do something like this:

    const resource = {
      reminders: {
        overrides: [
          {
            method: "popup", // options: "popup", "email"
            minutes: 5
          }
        ]
      }
    }
    Calendar.Events.patch(resource, calendarId, eventId);
    

    If you need more information about how to use Calendar API, take a look at the different quickstarts available, for example this one for JavaScript.

    Reference: