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]);

Constructors

Methods

  • Get Attachment

    Returns null | {
        mime: null | string;
        uri: string;
    }

    0.2.1

  • 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'
    }
    });

    Parameters

    • attachment: null | string | {
          mime?: null | string;
          uri: string;
      }

    Returns this

    0.2.1

  • 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.

    Returns null | string

    0.2.1

  • 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.

    Parameters

    • description: null | string

    Returns this

    0.2.1

  • 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

    Returns null | ICalAlarmRelatesTo

    4.0.1

  • 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

    Parameters

    Returns this

    4.0.1

  • Get Alarm Repetitions

    Returns null | ICalAlarmRepeatData

    0.2.1

  • 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
    }
    });

    Parameters

    Returns this

    0.2.1

  • Get the alarm summary. Used to set the email subject if alarm type is email. Defaults to the event's summary.

    Returns null | string

    7.0.0

  • Set the alarm summary. Used to set the email subject if alarm type is display. Defaults to the event's summary.

    Parameters

    • summary: null | string

    Returns this

    0.2.1

  • 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.

    Returns ICalAlarmJSONData

    0.2.4

  • Return generated event as a string.

    const alarm = event.createAlarm();
    console.log(alarm.toString()); // → BEGIN:VALARM…

    Returns string

  • 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.

    Returns number | ICalDateTimeValue

    0.2.1

  • 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.

    Parameters

    Returns this

    0.2.1

  • 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.

    Returns number | ICalDateTimeValue

    0.2.1

  • 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.

    Parameters

    Returns this

    0.2.1

  • 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.

    Parameters

    Returns this

    0.2.1

  • 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.

    Returns number | ICalDateTimeValue

    0.2.1

  • 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!"
    });

    Parameters

    • keyOrArray: [string, string][] | Record<string, string> | {
          key: string;
          value: string;
      }[]

    Returns this

    1.9.0

  • 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!");
    

    Parameters

    • keyOrArray: string
    • value: string

    Returns this

    1.9.0

  • Get all custom X-* attributes.

    Returns {
        key: string;
        value: string;
    }[]

    1.9.0