Code Monkey home page Code Monkey logo

capacitor-calendar's Introduction

capacitor-plugin-calendar

A plugin for Android to detect and watch for system theme changes. Currently the WebView does not populate the prefers-calendar property with their system dark mode.

TODO: Install

npm install capacitor-plugin-calendar
npx cap sync

Example

// Prompt to create event
const { id } = await Calendar.addEvent({
  title: 'Event Name',
  location: 'The World',
  startDate: new Date(),
  isAllDay: true,
});

// Update event
await Calendar.updateEvent({
  id,
  location: 'North Pole',
});

// Check event exists
const { result } = await Calendar.hasEvent({ id });

// Delete event
await Calendar.deleteEvent({ id });

Android Manifest

Ensure that you have the following permissions added

<?xml version='1.0' encoding='utf-8'?>
<manifest ...>
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />
</manifest>

API

requestAccess(...)

requestAccess(options: { fullAccess?: boolean; }) => Promise<{ result: CalendarPermissionResult; }>

Request access to the calendar

Param Type Description
options { fullAccess?: boolean; } Event options

Returns: Promise<{ result: CalendarPermissionResult; }>


hasAccess(...)

hasAccess(options: { fullAccess?: boolean; }) => Promise<{ result: CalendarPermissionResult; }>

Returns access level

Param Type Description
options { fullAccess?: boolean; } Event options

Returns: Promise<{ result: CalendarPermissionResult; }>


hasEvent(...)

hasEvent(options: { id: string; }) => Promise<{ result: boolean; }>

Returns true when provided id exists in the calendar

Param Type Description
options { id: string; } Event options

Returns: Promise<{ result: boolean; }>


addEvent(...)

addEvent(options: CalendarCreateEventOptions) => Promise<{ id: string; }>

Open device calendar with pre-fill event using provided information

Param Type Description
options CalendarCreateEventOptions Event information

Returns: Promise<{ id: string; }>


updateEvent(...)

updateEvent(options: CalendarUpdateEventOptions) => Promise<{ id: string; }>

Updates event with provided data by an id

Param Type Description
options CalendarUpdateEventOptions Event information

Returns: Promise<{ id: string; }>


removeEvent(...)

removeEvent(options: { id: string; }) => Promise<{ result: boolean; }>

Removes an event by its id

Param Type Description
options { id: string; } Event options

Returns: Promise<{ result: boolean; }>


Type Aliases

CalendarCreateEventOptions

CalendarEventOptions & { title: string; startDate: number; fullAccess?: boolean; }

CalendarEventOptions

{ title?: string; startDate?: number; notes?: string; location?: string; endDate?: number; isAllDay?: boolean; }

CalendarUpdateEventOptions

CalendarEventOptions & { id: string; }

Enums

CalendarPermissionResult

Members Value
NotDetermined 0
Authorized 1
Restricted 2
Denied 3

capacitor-calendar's People

Contributors

robholden avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.