Friendly-Aid
Friendly-Aid

Reputation: 11

adding events to IOS calendar using pythonista

I am trying to use pythonista to add events to the IOS calendar. I am trying to use EventKit through objc_util, but I can't seem to get it to work.

I have tried searching up how to do it and used AI, but nothing is working. the code I currently have is

import objc_util
import datetime

# Get necessary classes from the EventKit framework
EKEventStore = objc_util.ObjCClass('EKEventStore')
EKEvent = objc_util.ObjCClass('EKEvent')

# Initialize an EKEventStore instance
event_store = EKEventStore.new()
new_event=EKEvent.eventWithEventStore_(event_store)
new_event.setTitle_("Test Event")
new_event.setStartDate_(objc_util.ns(datetime.datetime(2024, 12, 15, 10, 0)))  # Dec 15, 2024, 10:00 AM
new_event.setEndDate_(objc_util.ns(datetime.datetime(2024, 12, 15, 11, 0)))    # Dec 15, 2024, 11:00 AM

event_store.saveEvent_span_error_(new_event,0,None)

which I expected to add A event to my calendar but it didn't, and the code doesn't give any errors.

P.S. I have managed to give calendar permissions to pythonista. proof of giving calendar permissions

thank you for taking your time to read this.

Upvotes: 0

Views: 45

Answers (0)

Related Questions