All Projects → thxou → Klendario

thxou / Klendario

Licence: MIT License
A Swift wrapper over the EventKit framework

Programming Languages

swift
15916 projects
objective c
16641 projects - #2 most used programming language
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Klendario

Fb2cal
Fetch Facebook Birthdays events and create an ICS file for use with calendar apps
Stars: ✭ 335 (+661.36%)
Mutual labels:  events, calendar
Laravel Google Calendar
Manage events on a Google Calendar
Stars: ✭ 787 (+1688.64%)
Mutual labels:  events, calendar
Cadar
Android solution which represents month and list calendar views.
Stars: ✭ 360 (+718.18%)
Mutual labels:  events, calendar
contao-events subscriptions
Contao extension that allows members of your website to subscribe to the events
Stars: ✭ 12 (-72.73%)
Mutual labels:  events, calendar
Quasar Ui Qcalendar
QCalendar - Quasar App Extension, Vue CLI plug-in and UMD distributions available
Stars: ✭ 148 (+236.36%)
Mutual labels:  events, calendar
sugarcalendar-core
Sugar Calendar plugin for WordPress
Stars: ✭ 40 (-9.09%)
Mutual labels:  events, calendar
node-google-calendar
Simple node module that supports Google Calendar API
Stars: ✭ 76 (+72.73%)
Mutual labels:  events, calendar
Koyomi
Simple customizable calendar component in Swift 📆
Stars: ✭ 716 (+1527.27%)
Mutual labels:  calendar, carthage
Flutter Timeline
⌚️ A general flutter timeline widget based on real-world application references
Stars: ✭ 142 (+222.73%)
Mutual labels:  events, calendar
Ls.joyous
A calendar application for Wagtail
Stars: ✭ 53 (+20.45%)
Mutual labels:  events, calendar
Kvkcalendar
A most fully customization calendar and timeline library for iOS 📅
Stars: ✭ 160 (+263.64%)
Mutual labels:  calendar, carthage
Shift
Light-weight EventKit wrapper.
Stars: ✭ 31 (-29.55%)
Mutual labels:  calendar, eventkit
Calendarkit
📅 Calendar for Apple platforms in Swift
Stars: ✭ 2,049 (+4556.82%)
Mutual labels:  calendar, ios-calendar
networkdays
Networkdays functions ... including `networkdays` excel like function with no dependencies (no NumPy)
Stars: ✭ 22 (-50%)
Mutual labels:  events, calendar
Fscalendar
A fully customizable iOS calendar library, compatible with Objective-C and Swift
Stars: ✭ 9,829 (+22238.64%)
Mutual labels:  calendar, carthage
Calendar
Календарь событий по фронтенду
Stars: ✭ 395 (+797.73%)
Mutual labels:  events, calendar
Datez
📆 Breeze through Date, DateComponents, and TimeInterval with Swift!
Stars: ✭ 254 (+477.27%)
Mutual labels:  calendar, carthage
Forcal
📅 Das AddOn ist ein variabel einsetzbarer Kalender(-Generator), Skedule, Newssystem, Event- und Terminplaner für REDAXO 5.x.
Stars: ✭ 52 (+18.18%)
Mutual labels:  events, calendar
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:  events, calendar
wp-event-calendar
The best way to manage events in WordPress
Stars: ✭ 46 (+4.55%)
Mutual labels:  events, calendar

Overview

Pod Version Pod Platform Carthage compatible Pod License

Klendario is a Swift wrapper over the EventKit framework. It adds simplicity to the task of managing events in the iOS Calendar by providing handfull functions, extensions and the semi-automatic managment of the user authorization request to access the iOS calendar.

Requirements

  • iOS 9.0+
  • Xcode 10.0+
  • Swift 4.2+

Install

Cocoapods

Add this line to your podfile:

pod 'Klendario'

Carthage

Add this line to your cartfile:

github "ThXou/Klendario" ~> 1.0

And then follow the official documentation about Adding frameworks to an application.

Setup

Import Klendario in your source file:

import Klendario

Then set the NSCalendarsUsageDescription usage description key in your app's Info.plist file to avoid the Xcode crash on access to sensitive data.

Authorization

Almost every call will check the user authorization status and returns an error in case the user has not authorized the access to the calendar. If the authorization has not been determined yet, the user is prompted to authorize the application. Anyway you can request authorization manually by calling:

Klendario.requestAuthorization { (granted, status, error) in
    if let error = error {
        print("error: \(error.localizedDescription)")
    } else {
        print("authorization granted!")
    }
}

The closure will return an error if the user has denied the access or if the access is restricted due to, for example, parental controls.

If you prefer, you can check if the user has granted access to the calendar using:

Klendario.isAuthorized()

Events

Creating events

Create an event is as easy as this:

let event = Klendario.newEvent()
event.title = "Awesome event"
event.startDate = Date()
event.endDate = Date().addingTimeInterval(60*60*2) // 2 hours
event.save()

If you have the specific calendar where you want to add the event, you can pass it in the newEvent() function as a parameter. If you additionaly want to perform some actions on saving, you can use the optional completion closure:

...
event.save { error in
   if let error = error {
      print("error: \(error.localizedDescription)")
   } else {
      print("event successfully created!")
   }
}

Before saving events read the Last but not least section.

Getting events

Get a single event

You can get an event by knowing its event identifier:

Klendario.getEvent(with: eventIdentifier) { (event, error) in
    guard let event = event else { return }
    print("got an event: \(event.title ?? "")")
}

Get a group of events

Or you can get a group of events between two dates and in specific calendars:

Klendario.getEvents(from: Date(),
                    to: Date() + 60*60*2,
                    in: calendars) { (events, error) in
                        guard let events = events else { return }
                        print("got \(events.count) events")
}

Deleting events

You can easily delete an EKEvent object using the delete function:

event.delete()

As for creating an event, you can perform actions on event deletion completion. You can omit any paremeter:

event.delete(span: .futureEvents, commit: false) { error in
    if let error = error {
        print("error: \(error.localizedDescription)")
    } else {
        print("event successfully deleted!")
    }
}

Before deleting events read the Last but not least section.

Calendars

Creating calendars

Create a new calendar is as easy as create a new event:

let calendar = Klendario.newCalendar()
calendar.title = "Awesome calendar"
calendar.save()

As for events, you can use a completion closure to handle possible errors or perform some action on task completion. This method is flexible so you can pass a different eventStore or source if you don't want to use the default one.

Before saving calendars read the Last but not least section.

Getting calendars

To get all the iOS calendars which includes events in the device, simply call:

let calendars = Klendario.getCalendars()

Deleting calendars

You can easily delete an EKCalendar object using the delete function:

calendar.delete()

As for creating an event, you can perform actions on event deletion completion. You can omit any paremeter:

calendar.delete(commit: true) { error in
	if let error = error {
        print("error: \(error.localizedDescription)")
    } else {
        print("calendar successfully deleted!")
    }
}

Before deleting calendars read the Last but not least section.

Last but not least

It is very simple to save or delete an event or a calendar with Klendario, you just need to call save() or delete() on the object as shown in previous sections. Be carefull to not call save() or delete() on objects not retrieved with the Klendario API, because it shares the same EKEventStore object across all the API calls.

EventKit does not support cross-store saving at least until iOS 12.

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].