Calendar

The purpose of the calendar integration is to make it possible to interact with the calendar on the device.

Introduction

Using the calendar integration you will be able to connect to the calendar on the device running the app. This way you can create, read, update and delete events in the calendar.

Where to find: startiapp.Calendar

Data storage in the app

When an event is added through the app a key pair will be saved on the device. The key pair contains the EventId and the corresponding SyncId. This way the app will always be able to find the SyncId for a saved event (unless the app has been deleted from the device).

If the device is running Android 6.0+ (API 23) that it set to Auto Backup the data will stay on the phone. Auto Backup can be disabled by following this guide →.

Methods

isAccessGranted

isAccessGranted(): Promise<bool>

Returns a boolean indicating wether there are access to the calendar on the device.

requestAccess

requestAccess(): Promise<bool>

Asks the user about permission to access the calendar. Returns a boolean indicating wether the call completed successfully or not. So the value returned can’t be used to decide if there are access to the calendar. Here a following call to isAccessGranted() is necessary.

listCalendars

listCalendars(): Promise<{ id: string, name: string }[]>

Returns a list of available calendars on the phone. For each calendar an id and a name is returned.

addEvent

addEvent(
  calendarId: string,
  name: string,
  description: string,
  syncId: string,
  startDateTime: Date,
  endDateTime: Date): Promise<{result: bool, syncId: string, error: string}>

Adds an event to the calendar with the given calendarId and syncId. Returns an object where the result property indicates success or failure to add the event. syncId matches the given syncId and error will contain an error message if result is false.

deleteEvent

deleteEvent(eventId: string): Promise<{result: bool, eventId: string, error: string}>

Deletes the event with the given eventId. Returns an object containing the same properties as the addEvent method.

listEvents

listEvents(
  calendarId: string,
  from: Date,
  to: Date):
  Promise<{
    calendarId: string,
    eventId: string,
    title: string,
    description: string,
    syncId: string,
    startDate: Date,
    endDate: Date
  }[]>

Returns a list of event within the given time span defined in the two parameters from and to from the given calendar.