getCalendars(options)

デバイスのネイティブカレンダーアプリケーションから、利用可能なすべてのカレンダーを返します。必要に応じて、カレンダーへのアクセス権を付与するユーザに、権限ポップアップを最初に表示します。

構文 

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

パラメータ 

戻り値 

Calendar オブジェクトの配列として解決される Promise オブジェクト。エラーが発生すると、配列は空になります。

使用方法 

この関数は、デバイスカレンダーを 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  });
  • この関数は、他の CalendarService 機能を使用するための前提条件となります。つまり、この関数は、getCalendarService() を除く他の CalendarService 関数よりも前に呼び出す必要があります。
  • エラーが発生すると、却下された Promise を介してエラーが返されます。catch 句でエラーを処理します。

The Japanese Summer '24 guide is now live

日本語の Summer '24 ガイドが公開されました! 「Component Reference (コンポーネントリファレンス)」は、以前と同様にコンポーネントライブラリにあります。