Home

Awesome

React Native Calendar Reminders

React Native Module for IOS Calendar Reminders

Install

npm install --save react-native-calendar-reminders

Link Library

react-native link react-native-calendar-reminders

plist - Usage Description

Setting up privacy usage descriptions may also be require depending on which iOS version is supported. This involves updating the Property List, Info.plist, with the corresponding key for the EKEventStore api. Info.plist reference.

For updating the Info.plist key/value via Xcode, add a Privacy - Reminders Usage Description key with a usage description as the value.

Usage

Require the react-native-calendar-reminders module.

import RNCalendarReminders from 'react-native-calendar-reminders';

Properties

PropertyValueDescription
idString (read only)Unique id for the reminder.
calendarIdString (write only)Unique id for the calendar where the reminder will be saved. Defaults to the device's default calendar.
titleStringThe title for the reminder.
startDateDateThe start date of the reminder.
dueDateDateThe date by which the reminder should be completed.
completionDateDate (read only)The date on which the reminder was completed.
locationStringThe location associated with the reminder.
notesStringThe notes associated with the reminder.
alarmsArrayThe alarms associated with the reminder, as an array of alarm objects.
recurrenceStringThe simple recurrence frequency of the reminder ['daily', 'weekly', 'monthly', 'yearly'].
recurrenceIntervalStringThe interval between instances of this recurrence. For example, a weekly recurrence rule with an interval of 2 occurs every other week. Must be greater than 0.
isCompletedBoolA Boolean value determining whether or not the reminder is marked completed.
calendarObject (read-only)The calendar containing the reminder.

authorizationStatus

Get authorization status for IOS EventStore.

RNCalendarReminders.authorizationStatus()

Returns: Promise

Example:

RNCalendarReminders.authorizationStatus()
  .then(status => {
    // handle status
  })
  .catch(error => {
   // handle error
  });

authorizeEventStore

Request authorization to IOS EventStore. Authorization must be granted before accessing calendar events.

RNCalendarReminders.authorizeEventStore()

Returns: Promise

Example:

RNCalendarReminders.authorizeEventStore()
  .then(status => {
    // handle status
  })
  .catch(error => {
   // handle error
  });

findReminderById

Find calendar reminder by id. Returns a promise fulfilled with found reminder.

RNCalendarReminders.findEventById(id)

Parameters:

Returns: Promise

Example:

RNCalendarReminders.findEventById('FE6B128F-C0D8-4FB8-8FC6-D1D6BA015CDE')
  .then(event => {
    // handle reminder
  })
  .catch(error => {
   // handle error
  });

fetchAllReminders

Find all reminders.

RNCalendarReminders.fetchAllReminders()

Returns: Promise

Example:

RNCalendarReminders.fetchAllReminders()
  .then(reminders => {
    // handle reminders
  })
  .catch(error => {
   // handle error
  });

fetchCompletedReminders

Finds completed reminders in a set of calendars within an optional range.

RNCalendarReminders.fetchCompletedReminders()

Parameters:

Returns: Promise

Example:

RNCalendarReminders.fetchCompletedReminders(startDate, endDate)
  .then(reminders => {
    // handle reminders
  })
  .catch(error => {
   // handle error
  });

fetchIncompleteReminders

Finds incomplete reminders in a set of calendars within an optional range.

RNCalendarReminders.fetchIncompleteReminders(startDate, endDate)

Parameters:

Returns: Promise

Example:

RNCalendarReminders.fetchIncompleteReminders(startDate, endDate)
  .then(reminders => {
    // handle reminders
  })
  .catch(error => {
   // handle error
  });

saveReminder

Creates a new reminder.

RNCalendarReminders.saveReminder(title, settings);

Parameters:

Returns: Promise

Example:

RNCalendarReminders.saveReminder('title', {
    location: 'location',
    notes: 'notes',
    startDate: '2016-10-01T09:45:00.000UTC'
  })
  .then(id => {
    // handle success
  })
  .catch(error => {
   // handle error
  });

Create reminder with alarms

Alarm options:

PropertyValueDescription
dateDate or NumberIf a Date is given, an alarm will be set with an absolute date. If a Number is given, an alarm will be set with a relative offset (in minutes) from the start date.
structuredLocationObjectThe location to trigger an alarm.

Alarm structuredLocation properties:

PropertyValueDescription
titleStringThe title of the location.
proximityStringA value indicating how a location-based alarm is triggered. Possible values: enter, leave, none.
radiusNumberA minimum distance from the core location that would trigger the reminder's alarm.
coordsObjectThe geolocation coordinates, as an object with latitude and longitude properties

Example with date:

RNCalendarReminders.saveReminder('title', {
  location: 'location',
  notes: 'notes',
  startDate: '2016-10-01T09:45:00.000UTC',
  alarms: [{
    date: -1 // or absolute date
  }]
});

Example with structuredLocation:

RNCalendarReminders.saveReminder('title', {
  location: 'location',
  notes: 'notes',
  startDate: '2016-10-01T09:45:00.000UTC',
  alarms: [{
    structuredLocation: {
      title: 'title',
      proximity: 'enter',
      radius: 500,
      coords: {
        latitude: 30.0000,
        longitude: 97.0000
      }
    }
  }]
});

Example with recurrence:

RNCalendarReminders.saveReminder('title', {
  location: 'location',
  notes: 'notes',
  startDate: '2016-10-01T09:45:00.000UTC',
  alarms: [{
    date: -1 // or absolute date
  }],
  recurrence: 'daily'
});

Example with recurrenceInterval:

RNCalendarReminders.saveReminder('title', {
  location: 'location',
  notes: 'notes',
  startDate: '2016-10-01T09:45:00.000UTC',
  alarms: [{
    date: -1 // or absolute date
  }],
  recurrence: 'weekly',
  recurrenceInterval: '2'
});

updateReminder

Updates an existing reminder.

RNCalendarReminders.updateReminder(id, settings)

Parameters:

Returns: Promise

Example:

RNCalendarReminders.updateReminder('465E5BEB-F8B0-49D6-9174-272A4E5DEEFC', {
    title: 'another title',
    startDate: '2016-10-01T09:55:00.000UTC',
  })
  .then(id => {
    // handle success
  })
  .catch(error => {
   // handle error
  });

Or save save the reminder again with id property set in the optional settings.

Example:

RNCalendarReminders.saveReminder('title', {
    id: 'id',
    location: 'location',
    notes: 'notes',
    startDate: '2016-10-02T09:45:00.000UTC'
  })
  .then(id => {
    // handle success
  })
  .catch(error => {
   // handle error
  });

addAlarms

Update reminder with alarms. This will overwrite any alarms already set on the reminder.

RNCalendarReminders.addAlarms(id, alarms)

Parameters:

Returns: Promise

RNCalendarReminders.addAlarms('465E5BEB-F8B0-49D6-9174-272A4E5DEEFC', [{
    date: -2 // or absolute date
  }])
  .then(id => {
    // handle success
  })
  .catch(error => {
   // handle error
  });

addAlarm

Update reminder with added alarm

RNCalendarReminders.addAlarm(id, alarm)

Parameters:

Returns: Promise

RNCalendarReminders.addAlarm('465E5BEB-F8B0-49D6-9174-272A4E5DEEFC', {
    date: -3 // or absolute date
  })
  .then(id => {
    // handle success
  })
  .catch(error => {
   // handle error
  });

removeReminder

Remove existing reminder

Parameters:

Returns: Promise

RNCalendarReminders.removeReminder('465E5BEB-F8B0-49D6-9174-272A4E5DEEFC')
.then(successful => {
    // handle success
  })
  .catch(error => {
   // handle error
  });

findCalendars

Finds all the calendars on the device.

RNCalendarReminders.findCalendars();

Returns: Promise

Example:

RNCalendarEvents.findCalendars()
  .then(calendars => {
    // handle calendars
  })
  .catch(error => {
    // handle error
  });