You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For anyone that comes across this project and wants to know how to incorporate it into their own project, EventKit only works on macOS and in order to use it, you have to run your script in iTerm or Warp in order to ask for Calendar access. Running your script from VS Code or Terminal will not work.
Here is what I did to get the project set up:
Clone this repo to your machine
Copy the native folder and all the files inside of the src folder into your project
Make sure to install the following dependencies:
npm i node-mac-permissions ffi-napi
npm i ref-array-napi -D
cd into the native folder and run swift build to build the Swift binary
You're gonna have to fix all the typescript formatting issues on your own if you encounter them
Run your script: npm run dev | npm run start or whatever
How to access your events:
First check if you have permissions:
constpermissions=awaitEventKitJS.checkPermissions();// permissions is an object that returns {calendar: boolean, reminders: boolean}// I was unable to get reminders to work
Once you have gotten the correct permissions, you can now access the events on a calendar:
consteventStore=newEventKitJS.EventStore();constdateNow=newDate();constdateFuture=newDate();dateFuture.setHours(23,59);// As an example, this retrieves events from the current time to the end of the current dayconstpredicate=eventStore.predicateForEvents(dateNow,dateFuture);constevents=eventStore.events(predicate);
This looks like an awesome project! Would love to know how to implement this into my project :)
The text was updated successfully, but these errors were encountered: