Skip to content

Commit

Permalink
Prompt for calendar access from AppleScript
Browse files Browse the repository at this point in the history
See copious code comment for details on how I was able to get this
working.
  • Loading branch information
caleb531 committed Oct 4, 2023
1 parent 41f69a1 commit 42905bd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ocu/calendars/get-calendar-events.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ on run(listOfCalNames)

-- create event store and get the OK to access Calendars
set theEKEventStore to current application's EKEventStore's alloc()'s init()
-- trigger request for full access to calendar (this is crucial to ensure
-- that the workflow has calendar access); as of macOS Sonoma,
-- requestAccessToEntityType is deprecated (source:
-- <https://developer.apple.com/documentation/eventkit/ekeventstore/1507547-requestaccesstoentitytype>)
-- because the calendar permissions have become more granular (e.g. "Full
-- Access" vs. "Add Only"); the recommended alternative is to use
-- requestFullAccessToEventsWithCompletion (documentation here:
-- <https://developer.apple.com/documentation/eventkit/ekeventstore/4162272-requestfullaccesstoeventswithcom>)
theEKEventStore's requestFullAccessToEventsWithCompletion:(missing value)

-- get calendars that can store events
set theCalendars to theEKEventStore's calendarsForEntityType:0
-- filter down to the calendars you want
Expand Down

0 comments on commit 42905bd

Please sign in to comment.