Giter Club home page Giter Club logo

react-native-calendar-reminders's Introduction

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';
  • React-Native 0.40 and above use 1.1.0 and above
  • React-Native 0.39 and below use 1.0.0 and below

Properties

Property Value Description
id String (read only) Unique id for the reminder.
calendarId String (write only) Unique id for the calendar where the reminder will be saved. Defaults to the device's default calendar.
title String The title for the reminder.
startDate Date The start date of the reminder.
dueDate Date The date by which the reminder should be completed.
completionDate Date (read only) The date on which the reminder was completed.
location String The location associated with the reminder.
notes String The notes associated with the reminder.
alarms Array The alarms associated with the reminder, as an array of alarm objects.
recurrence String The simple recurrence frequency of the reminder ['daily', 'weekly', 'monthly', 'yearly'].
recurrenceInterval String The 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.
isCompleted Bool A Boolean value determining whether or not the reminder is marked completed.
calendar Object (read-only) The calendar containing the reminder.

authorizationStatus

Get authorization status for IOS EventStore.

RNCalendarReminders.authorizationStatus()

Returns: Promise

  • fulfilled: String - denied, restricted, authorized or undetermined
  • rejected: Error

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

  • fulfilled: String - denied, restricted, authorized or undetermined
  • rejected: Error

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:

  • id: String - The reminder's unique id.

Returns: Promise

  • fulfilled: Object | null - reminder.
  • rejected: Error

Example:

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

fetchAllReminders

Find all reminders.

RNCalendarReminders.fetchAllReminders()

Returns: Promise

  • fulfilled: Array - List of reminders
  • rejected: Error

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:

  • startDate: Date - The starting bound of the range to search.
  • endDate: Date - The ending bound of the range to search.

Returns: Promise

  • fulfilled: Array - List of completed reminders from range
  • rejected: Error

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:

  • startDate: Date - The starting bound of the range to search.
  • endDate: Date - The ending bound of the range to search.

Returns: Promise

  • fulfilled: Array - List of incomplete reminders from range
  • rejected: Error

Example:

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

saveReminder

Creates a new reminder.

RNCalendarReminders.saveReminder(title, settings);

Parameters:

  • title: String - The title of the reminder.
  • settings: Object - The settings for the reminder. See available properties above.

Returns: Promise

  • fulfilled: String - ID of created reminder
  • rejected: Error

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:

Property Value Description
date Date or Number If 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.
structuredLocation Object The location to trigger an alarm.

Alarm structuredLocation properties:

Property Value Description
title String The title of the location.
proximity String A value indicating how a location-based alarm is triggered. Possible values: enter, leave, none.
radius Number A minimum distance from the core location that would trigger the reminder's alarm.
coords Object The 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:

  • id: String - The unique ID of the reminder to edit.
  • settings: Object - The settings for the reminder. See available properties above.

Returns: Promise

  • fulfilled: String - ID of updated reminder
  • rejected: Error

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:

  • id: String - The unique ID of the reminder to add alarms to.
  • alarm: Objec - Alarm to add to reminder. See available alarm properties above.

Returns: Promise

  • fulfilled: String - ID of reminder with alarms
  • rejected: Error
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:

  • id: String - The unique ID of the reminder to add alarms to.
  • alarms: Array - List of alarms to add to reminder. See available alarm properties above.

Returns: Promise

  • fulfilled: String - ID of reminder with alarms
  • rejected: Error
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:

  • id: String - The unique ID of the reminder to remove.

Returns: Promise

  • fulfilled: Bool - True if successful
  • rejected: Error
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

  • fulfilled: Array - A list of known calendars on the device
  • rejected: Error

Example:

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

react-native-calendar-reminders's People

Contributors

asommer70 avatar dsernst avatar hartmamt avatar henryw4k avatar lyahdav avatar wmcmahan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-calendar-reminders's Issues

Recurring reminder marked as done changes time of next notification.

To replicate:

  1. Add the following reminder:
        RNCalendarReminders.saveReminder('title', {
          notes: 'notes',
          startDate: '2016-10-01T09:45:00.000UTC',
          alarms: [{
            date: '2016-10-01T09:45:00.000UTC'
          }],
          recurrence: 'daily'
        });
  1. Exit app and go to reminders. And mark it as done.
  2. Refresh reminders by click show/hide completed if they don't update by themselves

When you click on info in reminders the alarm date is being changed and a due date has been added (which wasn't there when the reminder was added for the first time and is different from the alarm date).

Manual Linking

Hello. Is There a way of manually linking the library? I need it.
I Tried to run RNCalendarReminders.authorizedEventStore() and i got the error below

Screenshot_20200114-214624

I remember having the same error with react-native-calendar-events built by you. Thanks, you did a great job for that one.
and it was caused by unlinked project. I will be waiting for your response. thanks in advance.

Error installing library

A few issues I had during installation:

  1. I think the README is missing a note about running react-native link.
  2. After running that command, I had an error when compiling in Xcode where it was trying to build the RNCalendarReminders project but it failed because that project couldn't find React Native header files. I gave up on that approach and just manually added RNCalendarReminders.h and RNCalendarReminders.m to my Xcode project.
  3. Then I got an error along the lines of "RCTBridgeModule.h not found" in RNCalendarReminders.h. The fix was to change #import "RCTBridgeModule.h" to #import <React/RCTBridgeModule.h>. It's possible because of the version of React Native I'm using. I'm on 0.41.2 via Exponent
  4. Similar to the previous error, I got "RCTConvert.h not found" in RNCalendarReminders.m. I fixed by changing #import "RCTConvert.h" to #import <React/RCTConvert.h>.

No calendar has been set

I just tried this out on the iOS Simulator and on iPhone 4s but I keep getting No calendar has been set when I tried to saveReminder.

I tried restarting the phone, turn iCloud calendar and reminder on and off, set default calendar and default reminder. But didn't make any difference.

Help?

Support for alerts?

I really like this component, thanks for creating it. I would really like to implement a reminder with an alert 30 minutes prior. Can you support this?

Thanks

Errors when trying to fechAllReminders

I am getting error 'undefined is not an object:

import RNCalendarReminders from 'react-native-calendar-reminders';
const {NativeAppEventEmitter} = React;
RNCalendarReminders.fetchAllReminders(reminders => {...})

I'm pretty new to react-native/ios programming, is any any example code to start with get authorized access to event store and fetch reminders?

follow up: I just figured out on 'add EventKit.framework to project libraries', but can't adding the RNCalendarReminders into project libraries, and I'm not sure if I'm doing the right thing to fix the issue

follow up: I finally figured out how to adding the RNCalendarReminders into the project libraries. But still need full example guide on how to manipulate the event store.

Support to check if an item has been 'marked done'

Hi,

As we know, on the native iOS reminders app we can mark items done, once the task has been completed. Is there any way in which we can read that value in react native through this component, so that we know whether the particular reminder/task was completed or not?

I am sorry if this exists, I tried looking around but couldn't find this feature. Would be glad if this could be included!

Can't create customized recurrence reminders

Property Value Description
recurrence String The simple recurrence frequency of the reminder ['daily', 'weekly', 'monthly', 'yearly'].

We have an app that requires 3 month, 6 month, 9 month recurrences. The current setup doesn't allow for that. Was wondering if this feature will come someday.

Unable to create alarm

Hi there! I'm trying to create alarm for reminder but unsuccessful.
I've linked EventKit.framework & RNCalendarReminders in Build Phases, tried to set different data etc, but all my Reminders with alarm arr I create whatever I try to change appears in Reminder section, without any info regarding alarm. Do you have any Ideas what it could be?

P.S. NativeAppEmmiter imported, I've used events for creating Reminder with alarm you wrote in Readme.
P.S.S. I've downloaded app 'thehoick-habit-app' created by Adam (guy who wrote #9 ) but unfortunately, I didn't succeed also to rcv any alarm after setting new notification.

Do you have any ideas what it could be?
Thanks

Request for simpler function to update existing reminder

Hi @wmcmahan,

I was trying to update the reminder's isCompleted value from my application. Just to mark a reminder as completed, I don't want to use saveReminder and send all the details viz title, alarms, recurrence, notes, etc. Can we have an update method where if I say something like

        RNCalendarReminders.updateReminder(reminder.id, {
            id: reminder.id,
            isCompleted: reminder.isCompleted,
        });

it should keep the remaining values as it is, rather than resetting everything?

NPM yet?

Really looking to add this to my react-native app. Just curious to see if you plan on maintaining this?

Module RCTNativeAppEventEmitter is not a registered callable module

Hello!

I am also seeing the same exception as addressed in PR 9:
Module RCTNativeAppEventEmitter is not a registered callable module. in response to calling RNCalendarReminders.saveReminder() using RN 0.19. The PR fixes the issue for me.

I was able to reproduce this in a new react-native 0.19 app that includes nothing but react-native-calendar-reminders. Let me know if I can provide any other info.

Fatal Error on saving reminder with custom id

I want to add custom id to reminder but I'm getting this error but it works fine without setting id.

[fatal][tid:com.facebook.react.RNCalendarRemindersQueue] Exception '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]' was thrown while invoking saveReminder on target RNCalendarReminders with params (
"\U062a\U0648\U062c\U0647",
{
alarms = (
{
date = "2016-05-24T15:15:00.000Z";
}
);
id = 1c1b4ab9df774316a84ca989070d5ce8;
notes = Transaction;
startDate = "2016-05-24T15:15:00.000Z";
}
)

Module does not work in release build.

Nothing happens after saving the reminder.

It works on debug mode on simulator and even on device connected to the laptop but not on release.

Here's the code.

export const addScheduleItem = (data) => {
  return function(dispatch){
    dispatch({type: 'SCHEDULE_PROCESSING'});

    reminderData = {
      location: data.location,
      notes: data.notes,
      startDate: data.startDate,
      dueDate: data.startDate,
      alarms: [{
        date: data.startDate,
      }],
      recurrence: data.recurrence
    }
    RNCalendarReminders.saveReminder(data.title, reminderData);
    dispatch({type: 'SCHEDULE_ADDED', payload: reminderData});
  }
}

Module breaking android release build

I cannot even imagine where to begin debugging this, but for some unknown reason, and it quite frankly may actually have nothing to do with your module itself, but with this module installed, the android release build crashes, instantly on startup, like 5 screens away from where the module is even being used within the application.

Dev mode is fine, zero errors are raised anywhere for anything. I would expect that when building the android build steps would ignore everything to do with this, and as the module requiring this is only used when the device is IOS it should not even be looking for it even when it is on the relevant screen.

Any suggestions perhaps, I am hoping to avoid having to maintain 2 separate projects because of a button.

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.