0.1.1 • Published 7 years ago

react-native-calendarevents-android v0.1.1

Weekly downloads
12
License
-
Repository
github
Last release
7 years ago

react-native-calendarevents-android

Add events to user's calendar on Android.

Getting started

Manual install

  1. npm install react-native-calendarevents-android --save
  2. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add com.exilz.calendarevents.CalendarEventsPackage; to the imports at the top of the file
  • Add new CalendarEventsPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-calendarevents-android'
    project(':react-native-calendarevents-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-calendarevents-android')
  1. Insert the following lines inside the dependencies block in android/app/build.gradle:
    compile project(':react-native-calendarevents-android')
  1. Add permissions in your AndroidManifest.xml
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />

Usage

Example

import AndroidCalendarEvents from 'react-native-calendarevents-android';

AndroidCalendarEvents.addEvent(
    {
        title: 'Event title',
        startDate: Date.now(),
        endDate: Date.now() + 3600 * 1000,
        description: 'Event description',
        location: 'Paris, France'
    },
    (success) => console.log(success),
    (error) => console.log(error)
);

Methods

addEvent(options)

Open calendar event dialog

Supported options:

NameTypeDescription
titlestringEvent title (required)
startDatenumberStart date in milliseconds from epoch (required)
endDatenumberEnd date in milliseconds from epoch (optional)
descriptionstringDescription to be pre-filled (optional)
locationstringLocation to be pre-filled and looked for by Google (optional)

Android calendar react native events