目录

Calendar Service Best Practices

Use Cases

With the Calendar service, you can write events with time attributes as calendar events, and users can quickly access the corresponding services through the one-tap service function. In this way, various types of information can be managed in a unified manner. Select a template applicable to each typical scenario and fill in the fields based on the template format to ensure complete and consistent user experience.

The calendar events can be displayed to users through multiple entries, such as the notification center, home screen widget, and calendar application.

The one-tap service button is displayed in different scenarios as follows:

Development Preparations

For details, see the development procedure in the first three steps of Calendar Management.

  1. Import dependencies.

  2. Apply for permissions. When using Calendar Kit, declare the ohos.permission.READ_CALENDAR and ohos.permission.WRITE_CALENDAR permissions in the module.json5 file for reading and writing calendar events. For details, please refer to Declaring Permissions.

  3. Obtain the calendarMgr object based on the context to manage calendars. You are advised to perform managements in the EntryAbility.ets file.

Typical One-Tap Service Scenarios

The following table lists the typical one-tap service scenarios and the corresponding displayed content.

Type ServiceType Value Button Displayed Content
Meeting 'Meeting' Join Meeting
Watching TV series 'Watching' Watch
Repayment 'Repayment' Repay now
Live 'Live' Starting Livestreaming
Shopping 'Shopping' Shopping
View 'Trip' View
Start class 'Class' Start
Sports events 'SportsEvents' Watch
Exercise 'SportsExercise' Exercise

Before developing each scenario, ensure that related dependencies have been imported and related permissions have been requested. For details, see Development Preparations.

[h2]Mobility

After a user books a train ticket, flight ticket, or other transportation tickets on the ticket booking platform, the system can automatically add the trip information to the calendar and send a reminder at the appropriate time.

The following table lists the recommended configurations and description of the main fields in this scenario.

Field Corresponding Setting Recommended Value
Schedule title title Flight or train number, departure place, and destination
Start time startTime Start time of the trip
End time endTime End time of the trip
Reminder time reminderTime Reminders are sent 2 hours and 4 hours before the event.
Calendar account (displayed to the user in the calendar) displayName Ecosystem app name (It is recommended that the name be the same as that in AppGallery.)
Remarks description Additional information such as the ticket gate and seat number can be added.
One-tap service ServiceType calendarManager.ServiceType.TRIP
  1. Create a calendar event.

    // Index.ets
    import { calendarMgr } from '../entryability/EntryAbility';
    import { calendarManager } from '@kit.CalendarKit';
    
    let tripCalendar: calendarManager.Calendar | undefined = undefined;
    let oriEvent: calendarManager.Event | null = null;
    let id: number = 0;
    
    async createTripCalendarAndEvent(): Promise<void> {
      // Specify the calendar account information.
      const calendarAccount: calendarManager.CalendarAccount = {
        name: 'TripCalendar',
        type: calendarManager.CalendarType.LOCAL,
        // Display name of the calendar account. You are advised to use the actual name of the app.
        displayName: 'High-speed train travel'
      };
      // Calendar configuration information.
      const config: calendarManager.CalendarConfig = {
        // Set the calendar color.
        color: '#aabbcc'
      };
      const startTime = new Date('2025-10-01T08:17:00').getTime();
      const endTime = new Date('2025-10-01T12:51:00').getTime();
      // Schedule configuration information.
      const event: calendarManager.Event = {
        type: calendarManager.EventType.NORMAL,
        // Event title.
        title: 'Itinerary: G107 Shanghai Hongqiao - Beijing South',
        // Start time
        startTime: startTime,
        // End time
        endTime: endTime,
        // Whether the schedule is all-day.
        isAllDay:false,
        // Reminder time
        reminderTime:[120, 240],
        // Remarks
        description: 'Ticket gate: Gate 1 on the second floor of the south or waiting room B2 on the north square.\nSeat No.: Seat 4 in second class of train No. 02',
        // One-tap service
        service: {
          // Service type
          type: calendarManager.ServiceType.TRIP,
          // Service URI, which is in the DeepLink format. Set this parameter according to the one-touch service guide.
          uri: 'demo://mobile/player?params='
        }
      }
      try {
        // Create a calendar.
        tripCalendar = await calendarMgr?.createCalendar(calendarAccount);
        if (!tripCalendar || tripCalendar === null) {
          console.error('Failed to create calendar. tripCalendar is null.');
          return;
        }
        // Ensure that the calendar is successfully created before managing related events.
        // Set the calendar configuration information and the calendar account color.
        await tripCalendar.setConfig(config);
        // Add an event.
        id = await tripCalendar.addEvent(event);
        oriEvent = event;
        oriEvent.id = id;
        console.info(`Succeeded in creating calendar and event, result: ${JSON.stringify(id)}`);
      } catch (error) {
        console.error(`Failed to create calendar or event. Code: ${error.code}, message: ${error.message}`);
      }
    }
  2. Query events.

    // Index.ets
    async getTripEvent(): Promise<void> {
      // Check whether the calendar is empty.
      if (!tripCalendar || tripCalendar === null) {
        console.error('Failed to get event, calendar is null.');
        return;
      }
      try {
        // Query the schedule.
        const filter = calendarManager.EventFilter.filterById([id]);
        let data: calendarManager.Event[] = await tripCalendar.getEvents(filter, ['title', 'type', 'startTime', 'endTime']);
        if (data && data.length > 0) {
          oriEvent = data[0];
        }
        console.info(`Succeeded in getting events, data -> ${JSON.stringify(data)}`);
      } catch (err) {
        console.error(`Failed to get events. Code: ${err.code}, message: ${err.message}`);
      }
    }
  3. Update an event.

    // Index.ets
    async updateTripEvent(): Promise<void> {
      // Check whether the calendar is empty.
      if (!tripCalendar || tripCalendar === null) {
        console.error('Failed to update event, calendar is null.');
        return;
      }
      if (!oriEvent || oriEvent === null) {
        console.error('Failed to update event, oriEvent is null');
        return;
      }
      // Modify the start time and end time of the schedule.
      oriEvent.startTime = new Date('2025-10-01T07:03:00').getTime();
      oriEvent.endTime = new Date('2025-10-01T11:51:00').getTime();
      try {
        // Update the schedule.
        await tripCalendar.updateEvent(oriEvent);
        console.info('Succeeded in updating event');
      } catch (err) {
        console.error(`Failed to update event. Code: ${err.code}, message: ${err.message}`);
      }
    }
  4. Delete an event.

    // Index.ets
    async deleteTripEvent(): Promise<void> {
      // Check whether the calendar is empty.
      if (!tripCalendar || tripCalendar === null) {
        console.error('Failed to delete event, calendar is null.');
        return;
      }
      try {
        // Delete a trip.
        await tripCalendar.deleteEvent(id);
        oriEvent = null;
        console.info(`Succeeded in deleting Event`);
      } catch (err) {
        console.error(`Failed to delete Event, Code is ${err.code}, message is ${err.message}`);
      }
    }

[h2]Hotel Stay

The following table lists the recommended configurations and description of the main fields in this scenario.

Field Corresponding Setting Recommended Value
Schedule title title Hotel check-in information (hotel name and address)
Location location Geographical location of the hotel
Start time startTime Check-in time
End time endTime Check-out time
All-day events isAllDay true: indicates that an all-day event is added.
Reminder time reminderTime

0: The event is reminded at 9:00 a.m. of the current day (or the start time of the event if it is not an all-day event).

1440: The event is reminded at 9:00 a.m. of the previous day.

If this parameter is not set, no reminder is set.

Calendar account (displayed to the user in the calendar) displayName Ecosystem app name (It is recommended that the name be the same as that in AppGallery.)
Remarks description You can add the check-in time and check-out time.
One-tap service ServiceType calendarManager.ServiceType.TRIP

The following is an example of creating an event:

// Index.ets
async createHotelCalendarAndEvent(): Promise<void> {
  // Specify the calendar account information.
  const calendarAccount: calendarManager.CalendarAccount = {
    name: 'hotelCalendar',
    type: calendarManager.CalendarType.LOCAL,
    // Display name of the calendar account. You are advised to use the actual name of the app.
    displayName: 'Hotel stay',
  };
  // Calendar configuration information.
  const config: calendarManager.CalendarConfig = {
    // Set the calendar color.
    color: '#aabbcc'
  };
  const startTime = new Date('2025-05-01T15:00:00').getTime();
  const endTime = new Date('2025-05-02T12:00:00').getTime();
  // Schedule configuration information
  const event: calendarManager.Event = {
    type: calendarManager.EventType.NORMAL,
    title: 'Check-in information: Hotel (Shanghai Xintiandi branch)',
    location: {
      location: 'Shanghai Xintiandi',
      longitude: 121.47506199999998,
      latitude: 31.219150000000013
    },
    startTime: startTime,
    endTime: endTime,
    isAllDay: true,
    // Reminder time: The number of minutes before 9:00 is calculated for all-day events.
    reminderTime: [0, 1440],
    description: 'Check-in: after 15:00\nCheck-out: before 12:00',
    // One-tap service
    service: {
      type: calendarManager.ServiceType.TRIP,
      uri: 'demo://mobile/player?params='
    }
  }
  try {
    // Create a calendar.
    let data: calendarManager.Calendar | undefined= await calendarMgr?.createCalendar(calendarAccount);
    if (!data || data === null) {
      console.error('Failed to create calendar. data is null.');
      return;
    }
    // Ensure that the calendar is successfully created before managing related events.
    // Set the calendar configuration information and the calendar account color.
    await data.setConfig(config);
    // Add an event.
    id = await data.addEvent(event);
    console.info(`Succeeded in creating calendar and event, result: ${JSON.stringify(id)}`);
  } catch (error) {
    console.error(`Failed to create calendar or event. Code: ${error.code}, message: ${error.message}`);
  }
}

[h2]Live Streaming Reservation

The following table lists the recommended settings for the main fields in this scenario.

Field Corresponding Setting Recommended Value
Schedule title title Topic
Start time startTime Live streaming start time
End time endTime Live streaming end time
Reminder time reminderTime Reminder at the scheduled time and 10 minutes before the scheduled time
Calendar account (displayed to users in the calendar) displayName Ecosystem app name (It is recommended that the name be the same as that in AppGallery.)
Remarks description You can add details about the live streaming.
One-tap service ServiceType calendarManager.ServiceType.LIVE

The following is an example of creating an event:

// Index.ets
async createLiveCalendarAndEvent(): Promise<void> {
  // Specify the calendar account information.
  const calendarAccount: calendarManager.CalendarAccount = {
    name: 'liveCalendar',
    type: calendarManager.CalendarType.LOCAL,
    // Display name of the calendar account. You are advised to use the actual app name.
    displayName: 'Live flash sale'
  };
  // Calendar configuration information.
  const config: calendarManager.CalendarConfig = {
    // Set the calendar color.
    color: '#aabbcc'
  };
  const startTime = new Date('2025-11-04T21:00:00').getTime();
  const endTime = new Date('2025-11-04T22:00:00').getTime();
  // Schedule configuration information
  const event: calendarManager.Event = {
    type: calendarManager.EventType.NORMAL,
    title: 'Live shopping',
    startTime: startTime,
    endTime: endTime,
    isAllDay: false,
    reminderTime: [0, 10],
    description: 'Limited-time offer! Get the best deals of the season in our livestream.',
    // One-tap service
    service: {
      type: calendarManager.ServiceType.LIVE,
      uri: 'demo://mobile/player?params='
    }
  }
  try {
    // Create a calendar.
    let data: calendarManager.Calendar | undefined= await calendarMgr?.createCalendar(calendarAccount);
    if (!data || data === null) {
      console.error('Failed to create calendar. data is null.');
      return;
    }
    // Ensure that the calendar is successfully created before managing related events.
    // Set the calendar configuration information and set the calendar account color.
    await data.setConfig(config);
    // Add an event.
    id = await data.addEvent(event);
    console.info(`Succeeded in creating calendar and event, result: ${JSON.stringify(id)}`);
  } catch (error) {
    console.error(`Failed to create calendar or event. Code: ${error.code}, message: ${error.message}`);
  }
}

[h2]Live Shopping Reservation

The following table lists the recommended configurations and descriptions of the main fields in this scenario.

Field Corresponding Setting Recommended Value
Schedule title title Name of the shopping festival (flash sale)
Start time startTime Start time
End time endTime End time
Reminder time reminderTime Reminder at the scheduled time and 10 minutes before the scheduled time
Calendar account (displayed to users in the calendar) displayName Ecosystem app name (It is recommended that the name be the same as that in AppGallery.)
Remarks description You can add information about the shopping festival.
One-tap service ServiceType calendarManager.ServiceType.SHOPPING

The following is an example of creating a calendar event:

// Index.ets
async createShoppingCalendarAndEvent(): Promise<void> {
  // Specify the calendar account information.
  const calendarAccount: calendarManager.CalendarAccount = {
    name: 'shoppingCalendar',
    type: calendarManager.CalendarType.LOCAL,
    // Display name of the calendar account. You are advised to use the actual app name.
    displayName: 'Shopping'
  };
  // Calendar configuration information.
  const config: calendarManager.CalendarConfig = {
    // Set the calendar color.
    color: '#aabbcc'
  };
  const startTime = new Date('2025-12-19T19:00:00').getTime();
  const endTime = new Date('2025-12-19T20:00:00').getTime();
  // Calendar event configuration information
  const event: calendarManager.Event = {
    type: calendarManager.EventType.NORMAL,
    title: 'Shopping festival warm-up',
    startTime: startTime,
    endTime: endTime,
    isAllDay: false,
    reminderTime: [0, 10],
    description: 'Limited-time flash sale for 9.9, plus more special offers.',
    // One-tap service
    service: {
      type: calendarManager.ServiceType.SHOPPING,
      uri: 'demo://mobile/player?params='
    }
  }
  try {
    // Create a calendar.
    let data: calendarManager.Calendar | undefined= await calendarMgr?.createCalendar(calendarAccount);
    if (!data || data === null) {
      console.error('Failed to create calendar. data is null.');
      return;
    }
    // Ensure that the calendar is successfully created before managing related events.
    // Set the calendar configuration information and the color of the calendar account.
    await data.setConfig(config);
    // Add an event.
    id = await data.addEvent(event);
    console.info(`Succeeded in creating calendar and event, result: ${JSON.stringify(id)}`);
  } catch (error) {
    console.error(`Failed to create calendar or event. Code: ${error.code}, message: ${error.message}`);
  }
}

[h2]Repayment Reminder

The following table lists the recommended configurations and description of the main fields in this scenario.

Field Corresponding Setting Recommended Value
Schedule title title Repayment reminder
Start time startTime Repayment time
End time endTime Repayment time
All-day events isAllDay true: indicates that an all-day event is added.
Reminder time reminderTime

0: The event is reminded at 9:00 a.m. on the current day (or the start time of the event if it is not an all-day event).

If this parameter is not set, no reminder is set.

Calendar account (displayed to users in the calendar) displayName Ecosystem app name (It is recommended that the name be the same as that in AppGallery.)
Remarks description You can add the information about the amount to be repaid.
One-tap service ServiceType calendarManager.ServiceType.REPAYMENT

The following is an example of creating an event:

// Index.ets
async createRepaymentCalendarAndEvent(): Promise<void> {
  // Specify the calendar account information.
  const calendarAccount: calendarManager.CalendarAccount = {
    name: 'repaymentCalendar',
    type: calendarManager.CalendarType.LOCAL,
    // Display name of the calendar account. You are advised to use the actual name of the app.
    displayName: 'Finance',
  };
  // Calendar configuration information.
  const config: calendarManager.CalendarConfig = {
    // Set the calendar color.
    color: '#aabbcc'
  };
  const startTime = new Date('2025-10-20T00:00:00').getTime();
  const endTime = new Date('2025-10-20T23:59:59').getTime();
  // Schedule configuration information.
  const event: calendarManager.Event = {
    type: calendarManager.EventType.NORMAL,
    title: 'Repayment reminder',
    startTime: startTime,
    endTime: endTime,
    isAllDay: true,
    // For a full-day event, the reminder time 0 indicates that the event will be reminded at 9:00 a.m. on the current day.
    reminderTime: [0],
    description: 'This month\'s bill: 10,989.35 RMB to be paid',
    // One-tap service
    service: {
      type: calendarManager.ServiceType.REPAYMENT,
      uri: 'demo://mobile/player?params='
    }
  }
  try {
    // Create a calendar.
    let data: calendarManager.Calendar | undefined= await calendarMgr?.createCalendar(calendarAccount);
    if (!data || data === null) {
      console.error('Failed to create calendar. data is null.');
      return;
    }
    // Ensure that the calendar is successfully created before managing related events.
    // Set the calendar configuration information and the color of the calendar account.
    await data.setConfig(config);
    // Add an event.
    id = await data.addEvent(event);
    console.info(`Succeeded in creating calendar and event, result: ${JSON.stringify(id)}`);
  } catch (error) {
    console.error(`Failed to create calendar or event. Code: ${error.code}, message: ${error.message}`);
  }
}

[h2]Class Reminder

The following table lists the recommended settings for the main fields in this scenario.

Field Corresponding Setting Recommended Value
Schedule title title Course name
Start time startTime Course start time
End time endTime Course end time
Reminder time reminderTime Remind at the scheduled time and 10 minutes before the scheduled time
Calendar account (displayed to users in the calendar) displayName Ecosystem app name (It is recommended that the name be the same as that in AppGallery.)
Remarks description You can add course introduction.
One-tap service ServiceType calendarManager.ServiceType.CLASS

The following is an example of creating a schedule:

// Index.ets
async createClassCalendarAndEvent(): Promise<void> {
  // Specify the calendar account information.
  const calendarAccount: calendarManager.CalendarAccount = {
    name: 'classCalendar',
    type: calendarManager.CalendarType.LOCAL,
    // Display name of the calendar account. You are advised to use the actual app name.
    displayName: 'My schedule'
  };
  // Calendar configuration information.
  const config: calendarManager.CalendarConfig = {
    // Set the calendar color.
    color: '#aabbcc'
  };
  const startTime = new Date('2025-11-03T09:00:00').getTime();
  const endTime = new Date('2025-11-03T09:45:00').getTime();
  // Schedule configuration information
  const event: calendarManager.Event = {
    type: calendarManager.EventType.NORMAL,
    title: 'Chinese class',
    startTime: startTime,
    endTime: endTime,
    isAllDay: false,
    reminderTime: [0, 10],
    description: 'Prepare for poetry reading before the Chinese class.',
    // One-tap service
    service: {
      type: calendarManager.ServiceType.CLASS,
      uri: 'demo://mobile/player?params='
    }
  }
  try {
    // Create a calendar.
    let data: calendarManager.Calendar | undefined= await calendarMgr?.createCalendar(calendarAccount);
    if (!data || data === null) {
      console.error('Failed to create calendar. data is null.');
      return;
    }
    // Ensure that the calendar is successfully created before managing related events.
    // Set the calendar configuration information and set the calendar account color.
    await data.setConfig(config);
    // Add an event.
    id = await data.addEvent(event);
    console.info(`Succeeded in creating calendar and event, result: ${JSON.stringify(id)}`);
  } catch (error) {
    console.error(`Failed to create calendar or event. Code: ${error.code}, message: ${error.message}`);
  }
}

[h2]Entertainment

The following table lists the recommended configurations and description of the main fields in this scenario.

Field Corresponding Setting Recommended Value
Schedule title title Name
Start time startTime Start time of the event
End time endTime End time of the event
Reminder time reminderTime Remind at the scheduled time and 10 minutes before the scheduled time.
Calendar account (displayed to users in Calendar) displayName Ecosystem app name (It is recommended that the name be the same as that in AppGallery.)
Remarks description You can add information about the event.
One-tap service ServiceType calendarManager.ServiceType.SPORTS_EVENTS

The following is an example of creating a calendar event:

// Index.ets
async createSportsCalendarAndEvent(): Promise<void> {
  // Specify the calendar account information.
  const calendarAccount: calendarManager.CalendarAccount = {
    name: 'sportsEventsCalendar',
    type: calendarManager.CalendarType.LOCAL,
    // Display name of the calendar account. You are advised to use the actual app name.
    displayName: 'Football match'
  };
  // Calendar configuration information.
  const config: calendarManager.CalendarConfig = {
    // Set the calendar color.
    color: '#aabbcc'
  };
  const startTime = new Date('2025-10-19T20:00:00').getTime();
  const endTime = new Date('2025-10-19T21:30:00').getTime();
  // Calendar event configuration information.
  const event: calendarManager.Event = {
    type: calendarManager.EventType.NORMAL,
    title: '2026 Football League',
    startTime: startTime,
    endTime: endTime,
    isAllDay: false,
    reminderTime: [0, 10],
    description: 'First match of team xx in group A',
    // One-tap service
    service: {
      type: calendarManager.ServiceType.SPORTS_EVENTS,
      uri: 'demo://mobile/player?params='
    }
  }
  try {
    // Create a calendar.
    let data: calendarManager.Calendar | undefined= await calendarMgr?.createCalendar(calendarAccount);
    if (!data || data === null) {
      console.error('Failed to create calendar. data is null.');
      return;
    }
    // Ensure that the calendar is successfully created before managing related events.
    // Set the calendar configuration information and the color of the calendar account.
    await data.setConfig(config);
    // Add an event.
    id = await data.addEvent(event);
    console.info(`Succeeded in creating calendar and event, result: ${JSON.stringify(id)}`);
  } catch (error) {
    console.error(`Failed to create calendar or event. Code: ${error.code}, message: ${error.message}`);
  }
}

[h2]Fitness Training

The following table lists the recommended configurations and description of the main fields in this scenario.

Field Corresponding Setting Recommended Value
Schedule title title Training course name
Start time startTime Start time of the training
End time endTime End time of the training
Reminder time reminderTime Reminders are sent on time and 30 minutes before the event.
Calendar account (displayed to users in the calendar) displayName Ecosystem app name (It is recommended that the name be the same as that in AppGallery.)
Remarks description You can add the introduction to the exercise plan.
One-tap service ServiceType calendarManager.ServiceType.SPORTS_EXERCISE

The following is an example of creating an event:

// Index.ets
async createSportsExerciseEvent(): Promise<void> {
  // Specify the calendar account information.
  const calendarAccount: calendarManager.CalendarAccount = {
    name: 'sportsExerciseCalendar',
    type: calendarManager.CalendarType.LOCAL,
    // Display name of the calendar account. You are advised to use the actual name of the app.
    displayName: 'Health'
  };
  // Calendar configuration information.
  const config: calendarManager.CalendarConfig = {
    // Set the calendar color.
    color: '#aabbcc'
  };
  const startTime = new Date('2025-10-26T10:30:00').getTime();
  const endTime = new Date('2025-10-26T10:45:00').getTime();
  // Schedule configuration information
  const event: calendarManager.Event = {
    type: calendarManager.EventType.NORMAL,
    title: '15-minute fat burning workout without running or jumping',
    startTime: startTime,
    endTime: endTime,
    isAllDay: false,
    reminderTime: [0, 30],
    description: 'Day 17 of the training plan',
    // One-tap service
    service: {
      type: calendarManager.ServiceType.SPORTS_EXERCISE,
      uri: 'demo://mobile/player?params='
    }
  }
  try {
    // Create a calendar.
    let data: calendarManager.Calendar | undefined= await calendarMgr?.createCalendar(calendarAccount);
    if (!data || data === null) {
      console.error('Failed to create calendar. data is null.');
      return;
    }
    // Ensure that the calendar is successfully created before managing related events.
    // Set the calendar configuration information and the calendar account color.
    await data.setConfig(config);
    // Add an event.
    id = await data.addEvent(event);
    console.info(`Succeeded in creating calendar and event, result: ${JSON.stringify(id)}`);
  } catch (error) {
    console.error(`Failed to create calendar or event. Code: ${error.code}, message: ${error.message}`);
  }
}

[h2]Meeting

The following table lists the recommended settings for the main fields in this scenario.

Field Corresponding Setting Recommended Value
Schedule title title Meeting subject
Start time startTime Meeting start time
End time endTime Meeting end time
Participants attendee Attendee information
Reminder time reminderTime Reminders are sent on time and 15 minutes before the meeting.
Calendar account (displayed to users in the calendar) displayName Ecosystem app name (It is recommended that the name be the same as that in AppGallery.)
Remarks description You can add more information about the meeting.
One-tap service ServiceType calendarManager.ServiceType.MEETING

The following is an example of creating a schedule:

// Index.ets
async createMeetingEvent(): Promise<void> {
  // Specify the calendar account information.
  const calendarAccount: calendarManager.CalendarAccount = {
    name: 'meetingCalendar',
    type: calendarManager.CalendarType.LOCAL,
    // Display name of the calendar account. You are advised to use the actual app name.
    displayName: 'Meeting'
  };
  // Calendar configuration information.
  const config: calendarManager.CalendarConfig = {
    // Set the calendar color.
    color: '#aabbcc'
  };
  // Attendee information.
  let attendee: calendarManager.Attendee[] = [
    {
      name: 'Chris',
      email: 'test1@example.com',
      role: calendarManager.AttendeeRole.ORGANIZER
    },
    {
      name: 'Jack',
      email: 'test2@example.com',
      role: calendarManager.AttendeeRole.PARTICIPANT,
      type: calendarManager.AttendeeType.REQUIRED
    },
    {
      name: 'Jerry',
      email: 'test3@example.com',
      role: calendarManager.AttendeeRole.PARTICIPANT,
      type: calendarManager.AttendeeType.REQUIRED
    }
  ];
  const startTime = new Date('2025-10-20T09:00:00').getTime();
  const endTime = new Date('2025-10-20T10:00:00').getTime();
  // Schedule configuration information
  const event: calendarManager.Event = {
    type: calendarManager.EventType.NORMAL,
    title: 'xxx meeting',
    startTime: startTime,
    endTime: endTime,
    isAllDay: false,
    reminderTime: [0, 15],
    attendee: attendee,
    description: 'xx transaction review',
    // One-tap service
    service: {
      type: calendarManager.ServiceType.MEETING,
      uri: 'demo://mobile/player?params='
    }
  }
  try {
    // Create a calendar.
    let data: calendarManager.Calendar | undefined= await calendarMgr?.createCalendar(calendarAccount);
    if (!data || data === null) {
      console.error('Failed to create calendar. data is null.');
      return;
    }
    // Ensure that the calendar is successfully created before managing related events.
    // Set the calendar configuration information and set the calendar account color.
    await data.setConfig(config);
    // Add an event.
    id = await data.addEvent(event);
    console.info(`Succeeded in creating calendar and event, result: ${JSON.stringify(id)}`);
  } catch (error) {
    console.error(`Failed to create calendar or event. Code: ${error.code}, message: ${error.message}`);
  }
}