npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-add-calevent

v1.0.2

Published

creating events in react native using the standard iOS / Android dialogs

Downloads

21

Readme

react-native-add-calendar-event

This package differs from main one because this doesn't use any permissions on android. On the other functionality to edit event/ get event id is removed here.

This package alows you to start an activity (Android) or show a modal window (iOS) for adding or editing events in device's calendar. Through a promise, you can find out if a new event was added and get its id. See the usage section for more information. The functionality is provided through native modules and won't therefore work with Expo.

Getting started

npm install react-native-add-calendar-event --save

or

yarn add react-native-add-calendar-event

Mostly automatic installation

  1. react-native link react-native-add-calendar-event

  2. add NSCalendarsUsageDescription and NSContactsUsageDescription keys to your Info.plist file. The string value associated with the key will be used when asking user for calendar permission.

  3. rebuild your project

IOS note: If you use pods, react-native link will probably add the podspec to your podfile, in which case you need to run pod install. If not, please verify that the library is under link binary with libraries in the build settings in Xcode (see manual installation notes).

Usage

See the example folder for a demo app.

import * as AddCalendarEvent from 'react-native-add-calendar-event';

const eventConfig = {
  title,
  // and other options
};

AddCalendarEvent.presentEventDialog(eventConfig)
  .then((eventInfo: { calendarItemIdentifier: string, eventIdentifier: string }) => {
    // handle success - receives an object with `calendarItemIdentifier` and `eventIdentifier` keys, both of type string.
    // These are two different identifiers on iOS.
    // On Android, where they are both equal and represent the event id, also strings.
    // when false is returned, the dialog was dismissed
    if (eventInfo) {
      console.warn(JSON.stringify(eventInfo));
    } else {
      console.warn('dismissed');
    }
  })
  .catch((error: string) => {
    // handle error such as when user rejected permissions
    console.warn(error);
  });

supported options:

| Property | Value | Note | | :------------ | :------ | :------------------------------------------------------------------- | | eventId | String | Id of edited event. Do not pass if you want to add a new event. | | title | String | | | startDate | String | format: 'YYYY-MM-DDTHH:mm:ss.SSSZ' | | endDate | String | format: 'YYYY-MM-DDTHH:mm:ss.SSSZ' | | location | String | | | allDay | boolean | | | url | String | iOS only | | notes | String | The notes (iOS) or description (Android) associated with the event. | | useEditIntent | boolean | Android only, and only when editing an event. See description below. |

  • useEditIntent: ACTION_EDIT should work for editing events, according to android docs but this doesn't always seem to be the case as reported in the bug tracker. This option leaves the choice up to you. By default, the module will use ACTION_VIEW which will only show the event, but from there it is easy for the user to tap the edit button and make changes.

The dates passed to this module are strings. If you use moment, you may get the right format via momentInUTC.format('YYYY-MM-DDTHH:mm:ss.SSS[Z]') the string may look eg. like this: '2017-09-25T08:00:00.000Z'.

More options can be easily added, PRs are welcome!

It is recommended to not rely on the standard Date object and instead use some third party library for dealing with dates, such as moment.js because JavaScriptCore (which is used to run react-native on devices) handles dates differently from V8 (which is used when debugging, when the code runs on your computer).

Changing language of the dialog

see StackOverflow answer

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-add-calendar-event and add libRNAddCalendarEvent.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNAddCalendarEvent.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.vonovak.AddCalendarEventPackage; to the imports at the top of the file
  • Add new AddCalendarEventPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-add-calendar-event'
    project(':react-native-add-calendar-event').projectDir = new File(rootProject.projectDir,   '../node_modules/react-native-add-calendar-event/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-add-calendar-event')