getCalendars(options)

Returns all available calendars from the device’s native Calendar application. If needed, a permission pop-up for the user to grant calendar access is presented first.

Syntax 

1import { getCalendarService } from 'lightning/mobileCapabilities';
2getCalendars(options: CalendarServiceOptions): Promise<Object>

Parameters 

Returns 

A Promise object that resolves as an array of Calendar objects. If an error is encountered, the array is empty.

Usage 

Use this function to make device calendars available for use with CalendarService.

1myCalendarService
2  .getCalendars(options)
3  .then((results) => {
4    this.calendars = results;
5  })
6  .catch((error) => {
7    this.calendars = [];
8    console.error("Error code: " + error.code);
9    +console.error("Error message: " + error.message);
10  });
  • This function is a prerequisite for using any other CalendarService functionality; in other words, this function must be called before any other CalendarService function, except for getCalendarService().
  • If an error occurs, the error is returned via a rejected promise. Handle errors in a catch clause.

Release Preview

This release is in preview. Features described here don't become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can't guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.