All Projects → EddyVerbruggen → nativescript-calendar

EddyVerbruggen / nativescript-calendar

Licence: MIT License
📅 NativeScript plugin to Create, Delete and Find Events in the native Calendar

Programming Languages

typescript
32286 projects
shell
77523 projects

Projects that are alternatives of or similar to nativescript-calendar

Calendar Phonegap Plugin
📅 Cordova plugin to Create, Change, Delete and Find Events in the native Calendar
Stars: ✭ 729 (+1556.82%)
Mutual labels:  calendar, event
summit-app-ios
The official app for the OpenStack Summit
Stars: ✭ 35 (-20.45%)
Mutual labels:  calendar, event
React Native Add Calendar Event
Create, view or edit events in react native using the standard iOS / Android dialogs
Stars: ✭ 225 (+411.36%)
Mutual labels:  calendar, event
Ics Py
Pythonic and easy iCalendar library (rfc5545)
Stars: ✭ 322 (+631.82%)
Mutual labels:  calendar, event
Kotlin Agendacalendarview
Android calendar library provides easy to use widget with events
Stars: ✭ 81 (+84.09%)
Mutual labels:  calendar, event
Nativescript Ui Feedback
This repository is used for customer feedback regarding Telerik UI for NativeScript. The issues system here is used by customers who want to submit their feature requests or vote for existing ones.
Stars: ✭ 110 (+150%)
Mutual labels:  calendar, nativescript
add2calendar
📆 Allow you to add event to calendar easier
Stars: ✭ 51 (+15.91%)
Mutual labels:  calendar, event
ui
Add right-to-left support to the NativeScript framework
Stars: ✭ 22 (-50%)
Mutual labels:  nativescript
persian-date-time
Persian Date Time
Stars: ✭ 54 (+22.73%)
Mutual labels:  calendar
egg-bus
🐣 用 egg 编写优雅的队列与事件
Stars: ✭ 38 (-13.64%)
Mutual labels:  event
go-sunrise
Go package for calculating the sunrise and sunset times for a given location
Stars: ✭ 42 (-4.55%)
Mutual labels:  calendar
AndroidHotelCalendar
这是一个Android的酒店类型的日历选择空间,基于recyclerview实现
Stars: ✭ 33 (-25%)
Mutual labels:  calendar
node-google-calendar
Simple node module that supports Google Calendar API
Stars: ✭ 76 (+72.73%)
Mutual labels:  calendar
markdown-it-calendar
Automatically produced markdown-it-calendar
Stars: ✭ 23 (-47.73%)
Mutual labels:  calendar
moodle-tool trigger
Like IFTTT for Moodle: events to trigger external services. https://moodle.org/plugins/tool_trigger
Stars: ✭ 32 (-27.27%)
Mutual labels:  event
purescript-wire
Events and Signals for FRP. Monad instances included
Stars: ✭ 13 (-70.45%)
Mutual labels:  event
skywalking-kubernetes-event-exporter
Export Kubernetes events to Apache SkyWalking OAP.
Stars: ✭ 25 (-43.18%)
Mutual labels:  event
networkdays
Networkdays functions ... including `networkdays` excel like function with no dependencies (no NumPy)
Stars: ✭ 22 (-50%)
Mutual labels:  calendar
KM-MiniProgram
mini program for keep memory
Stars: ✭ 15 (-65.91%)
Mutual labels:  calendar
calendar-js
Pure calendar generator
Stars: ✭ 55 (+25%)
Mutual labels:  calendar

NativeScript Calendar Plugin

Build Status NPM version Downloads Twitter Follow

The Calendar plugin allows you to manipulate events in the user's native Calendar. You can find, create and delete events in either the default or a custom calendar.

If you're looking for an awesome in-app UI for the native calendar, then check this out.

Installation

From the command prompt go to your app's root folder and execute:

NativeScript 7

tns plugin add nativescript-calendar

NativeScript 6

tns plugin add [email protected]

iOS runtime permission reason

You probably have seen a permission popup like this before (this plugin will trigger one as well, automatically):

iOS 10+ requires not only this popup, but also a reason. In this case it's "Custom message from App_Resources".

You can provide your own reason for accessing the calendar by adding something like this to app/App_Resources/ios/Info.plist:

  <key>NSCalendarsUsageDescription</key>
  <string>My reason justifying fooling around with your calendar</string>

To not crash your app in case you forgot to provide the reason this plugin adds an empty reason to the .plist during build. This value gets overridden by anything you specified yourself. You're welcome.

TypeScript Usage

Of course you can use this plugin with TypeScript, just import the plugin and use the functions summed up below like this:

import * as Calendar from "nativescript-calendar";

// example for listCalendars:
Calendar.listCalendars().then(/* .. */);

Usage

If you want a quickstart, clone our demo app.

createEvent

  var Calendar = require("nativescript-calendar");

  // Only the `title`, `startDate` and `endDate` are mandatory, so this would suffice:
  var options = {
    title: 'Get groceries',
    // Make sure these are valid JavaScript Date objects.
    // In this case we schedule an Event for now + 1 hour, lasting 1 hour.
    startDate: new Date(new Date().getTime() + (60*60*1000)),
    endDate: new Date(new Date().getTime() + (2*60*60*1000))
  };

  // You can however add lots of properties to enrich the Event:
  options.location = 'The shop';
  options.notes = 'This event has reminders';

  // iOS has a separate 'url' field, but on Android the plugin appends this to the 'notes' field.
  options.url = 'http://my.shoppinglist.com';

  // You can also override the default reminder(s) of the Calendar (in minutes):
  options.reminders = {
    first: 30,
    second: 10
  };

  // You can make this Event recurring (this one repeats every other day for 10 days):
  options.recurrence = {
    frequency: "daily", // daily | weekly | monthly | yearly
    interval: 2, // once every 2 days
    endDate: new Date(new Date().getTime() + (10*24*60*60*1000)) // 10 days
  };

  // Want to use a custom calendar for your app? Pass in the 'name'.
  // If the name doesn't yet exist the plugin will create it for you.
  options.calendar = {
    name: "NativeScript Cal",
    // the color, in this case red
    color: "#FF0000",
    // Can be used on Android to group the calendars. Examples: Your app name, or an emailaddress
    accountName: "My App Name"
  };

  Calendar.createEvent(options).then(
      function(createdId) {
        console.log("Created Event with ID: " + createdId);
      },
      function(error) {
        console.log("Error creating an Event: " + error);
      }
  );

If you want an 'all day event', make sure you set the dates to midnight like this:

  var d = new Date();
  d.setHours(0);
  d.setMinutes(0);
  d.setSeconds(0);

  // this will create an 'all day event' for tomorrow
  var startDate = new Date(d.getTime() + (24*60*60*1000));
  var endDate = new Date(d.getTime() + (2*24*60*60*1000));
  // .. now use these properties in the options object

findEvents

  var options = {
    // when searching, dates are mandatory - the event must be within this interval
    startDate: new Date(new Date().getTime() - (50*24*60*60*1000)),
    endDate: new Date(new Date().getTime() + (50*24*60*60*1000))
  };

  // if you know the Event ID, set it here:
  options.id = '123456';

  // you can optionally pass in a few other properties, any event containing these will be returned:
  options.title = 'groceries';
  options.location = 'foo';
  options.notes = 'bar'; // iOS only

  Calendar.findEvents(options).then(
      function(events) {
        console.log(JSON.stringify(events));
      },
      function(error) {
        console.log("Error finding Events: " + error);
      }
  );

The returned 'events' object is an array of JSON events with these properties:

id
title
location
notes
url
startDate
endDate
allDay
calendar {id, name}
reminders {minutes}
recurrence {frequency, interval, endDate}
attendees {name, email, url, status, role, type}

deleteEvents

Usage is largely the same as findEvents, only the result is a bit different ;)

  var options = {
    // when searching, dates are mandatory - the event must be within this interval
    startDate: new Date(new Date().getTime() - (50*24*60*60*1000)),
    endDate: new Date(new Date().getTime() + (50*24*60*60*1000))
  };

  // if you know the Event ID, set it here:
  options.id = '123456';

  // you can optionally pass in a few other properties, any event containing these will be deleted:
  options.title = 'groceries'; // events _including_ this string will be included in the selection
  options.location = 'foo';
  options.notes = 'bar'; // iOS only

  Calendar.deleteEvents(options).then(
      function(deletedEventIds) {
        console.log(JSON.stringify(deletedEventIds));
      },
      function(error) {
        console.log("Error deleting Events: " + error);
      }
  )

listCalendars

  Calendar.listCalendars().then(
      function(calendars) {
        // a JSON array of Calendar objects is returned, each with an 'id' and 'name'
        console.log("Found these Calendars on the device: " + JSON.stringify(calendars));
      },
      function(error) {
        console.log("Error while listing Calendars: " + error);
      }
  )

deleteCalendar

TypeScript
import * as Calendar from "nativescript-calendar";

Calendar.deleteCalendar({
  name: "My Calendar name"
}).then(id => {
  // id is null if nothing was deleted
  console.log(`Deleted Calendar with id ${id}`);
});

Breaking changes in 2.0.0

See CHANGELOG.md.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].