Usually you get an ICalAlarm object like this:
import ical from 'ical-generator'; const calendar = ical(); const event = calendar.createEvent(); const alarm = event.createAlarm();
You can also use the ICalAlarm object directly:
import ical, {ICalAlarm} from 'ical-generator'; const alarm = new ICalAlarm(); event.alarms([alarm]);
ICalAlarm(data: ICalAlarmData,event: ICalEvent,)
Constructor of ICalAttendee. The event reference is required to query the calendar's timezone and summary when required.
Set Alarm attachment. Used to set the alarm sound if alarm type is audio. Defaults to "Basso".
const cal = ical(); const event = cal.createEvent(); event.createAlarm({ attach: 'https://example.com/notification.aud' }); // OR event.createAlarm({ attach: { uri: 'https://example.com/notification.aud', mime: 'audio/basic' } });
attendees(): ICalAttendee[]
Get all attendees
attendees(attendees: ()[]): this
Add multiple attendees to your event
createAttendee(data: ): ICalAttendee
Creates a new ICalAttendee and returns it. Use options to prefill the attendee's attributes. Calling this method without options will create an empty attendee.
description(): string | null
Get the alarm description. Used to set the alarm message
if alarm type is display
. If the alarm type is email
, it's
used to set the email body. Defaults to the event's summary.
description(description: string | null): this
Set the alarm description. Used to set the alarm message
if alarm type is display
. If the alarm type is email
, it's
used to set the email body. Defaults to the event's summary.
relatesTo(): ICalAlarmRelatesTo | null
Get to which time alarm trigger relates to.
Can be either START
or END
. If the value is
START
the alarm is triggerd relative to the event start time.
If the value is END
the alarm is triggerd relative to the event end time
relatesTo(relatesTo: ICalAlarmRelatesTo | null): this
Use this method to set to which time alarm trigger relates to.
Works only if trigger is a number
const cal = ical(); const event = cal.createEvent(); const alarm = cal.createAlarm(); alarm.trigger(600); // -> 10 minutes before event starts alarm.relatesTo('START'); // -> 10 minutes before event starts alarm.relatesTo('END'); // -> 10 minutes before event ends alarm.trigger(-600); // -> 10 minutes after event starts alarm.relatesTo('START'); // -> 10 minutes after event starts alarm.relatesTo('END'); // -> 10 minutes after event ends
repeat(): ICalAlarmRepeatData | null
Get Alarm Repetitions
repeat(repeat: ICalAlarmRepeatData | null): this
Set Alarm Repetitions. Use this to repeat the alarm.
const cal = ical(); const event = cal.createEvent(); // repeat the alarm 4 times every 5 minutes… cal.createAlarm({ repeat: { times: 4, interval: 300 } });
Get the alarm summary. Used to set the email subject
if alarm type is email
. Defaults to the event's summary.
Set the alarm summary. Used to set the email subject if alarm type is display. Defaults to the event's summary.
Return a shallow copy of the alarm's options for JSON stringification. Third party objects like moment.js values are stringified as well. Can be used for persistence.
Return generated event as a string.
const alarm = event.createAlarm(); console.log(alarm.toString()); // → BEGIN:VALARM…
Get the trigger time for the alarm. Can either be a date and time value (ICalDateTimeValue) or a number, which will represent the seconds between alarm and event start. The number is negative, if the alarm is triggered after the event started.
trigger(trigger: ): this
Use this method to set the alarm time.
const cal = ical(); const event = cal.createEvent(); const alarm = cal.createAlarm(); alarm.trigger(600); // -> 10 minutes before event starts alarm.trigger(new Date()); // -> now
You can use any supported date object, see readme for details about supported values and timezone handling.
Get the trigger time for the alarm. Can either be a date and time value (ICalDateTimeValue) or a number, which will represent the seconds between alarm and event start. The number is negative, if the alarm is triggered before the event started.
triggerAfter(trigger: number | ICalDateTimeValue): this
Use this method to set the alarm time. Unlike trigger
, this time
the alarm takes place after the event has started.
const cal = ical(); const event = cal.createEvent(); const alarm = cal.createAlarm(); alarm.trigger(600); // -> 10 minutes after event starts
You can use any supported date object, see readme for details about supported values and timezone handling.
triggerBefore(trigger: number | ICalDateTimeValue): this
Get the trigger time for the alarm. Can either be a date and time value (ICalDateTimeValue) or a number, which will represent the seconds between alarm and event start. The number is negative, if the alarm is triggered after the event started.
Use this method to set the alarm time.
const cal = ical(); const event = cal.createEvent(); const alarm = cal.createAlarm(); alarm.trigger(600); // -> 10 minutes before event starts alarm.trigger(new Date()); // -> now
You can use any supported date object, see readme for details about supported values and timezone handling.
type(type: ICalAlarmType): this
Get the alarm type
Set the alarm type. See ICalAlarmType for available status options.
x(keyOrArray: ): this
Set X-* attributes. Woun't filter double attributes, which are also added by another method (e.g. type), so these attributes may be inserted twice.
alarm.x([ { key: "X-MY-CUSTOM-ATTR", value: "1337!" } ]); alarm.x([ ["X-MY-CUSTOM-ATTR", "1337!"] ]); alarm.x({ "X-MY-CUSTOM-ATTR": "1337!" });
Set a X-* attribute. Woun't filter double attributes, which are also added by another method (e.g. type), so these attributes may be inserted twice.
alarm.x("X-MY-CUSTOM-ATTR", "1337!");