EventKit

RSS for tag

Create, view, and edit calendar and reminder events using EventKit and EventKitUI. Request read-only, write-only, or full-access to Calendar data.

EventKit Documentation

Posts under EventKit tag

60 Posts
Sort by:
Post not yet marked as solved
0 Replies
239 Views
iOS and macOS native calendar application detects URL's from video conferencing apps (e.g. Webex, Zoom, Microsoft Teams, Google Meet etc.). Even though these apps are not installed on the iPhone, it detects from the URL that the URL is of video conferencing/voip app and shows a 'Join' button next to URL and video icon, also the application icon if application is already installed on phone and tapping "Join" will redirect to app and Joins meeting. For example if the URL is for Zoom meeting is pasted in the iOS or macOS native Calendar event, it shows are Zoom meeting with "Join" button and video icon to indicated it video conference. Does apple provide and api for this integration, I have app which also do a video conference with URL, what is the way to make my app's URL recognized as Video Conference and show "Join" button as other above mentioned application. Does anyone know how to achieve this or made it work for their application. Appreciate any help, thanks
Posted
by
Post not yet marked as solved
0 Replies
323 Views
Hello, I have an app that I would like to have read and write access to Reminders using EventKit, but on MacOS 14 (14.2.1) when I call requestFullAccessToReminders I get error = nil, success = false (even when access is granted) and there is no permission prompt to use user when access has not yet been granted. Note this is not an issue in iOS. Here's a stripped down example of what I'm talking about import EventKit struct ContentView: View { let store = EKEventStore() @State var permissionState = "Ready to Request" var body: some View { VStack { Text(permissionState).font(.title) Button("Request Access") { requestFullAccessToEvents() }.padding() } .padding() } func requestFullAccessToEvents() { store.requestFullAccessToReminders { (granted, error) in if let foundError = error { permissionState = "Error: " + foundError.localizedDescription } else if granted { permissionState = "Permission Granted" } else { permissionState = "Permission Denied" } } } } then the plist <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>NSRemindersFullAccessUsageDescription</key> <string>something meaningful</string> </dict> </plist> I managed to find an error in the log saying Received error from calaccessd connection: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.CalendarAgent was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.CalendarAgent was invalidated: failed at lookup with error 159 - Sandbox restriction.}. Attempting to call any reply handler. So in the Signing & Capabilities tab I added Calendars to the App Sandbox, and that seemed to fix the issue, after that the user gets prompted for access to Reminders as expected or gets access depending on the access granted. Then I tried to release the app and I got rejected from the App Store because my app isn't using calendars, but of course I'm asking for access in the sandbox. So is this the wrong way to get permission for access, and if so, what is the correct way? Thanks!
Posted
by
Post not yet marked as solved
0 Replies
319 Views
EKEventStore on Apple Watch is not giving me all calendars. I can see only calendars of the source 'Subscriptions', but non of the calendars of source CalDAV (iCloud). This problem exists over multiple apps. Code works fine on iPhone. Any ideas? Minimal example code: import SwiftUI import EventKit struct ContentView: View { let eventStore = EKEventStore() @State var success: Bool = false @State var calendarNames: [String] = [String]() func request() async { success = (try? await eventStore.requestFullAccessToEvents()) ?? false } func list() { calendarNames = eventStore.calendars(for: .event).map { $0.title } } var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Access: \(success.description)") ScrollView { ForEach(calendarNames, id: \.self) { name in Text(name) } } } .onAppear { Task { await request() list() } } .padding() } }
Posted
by
Post not yet marked as solved
0 Replies
326 Views
I have a watch app that is supposed to access the calendar and display information about the event and then count down until that event. But ever since the IOS 17.0.0 and watchOS 14.0.0, the old method of requesting access does not work (though it still works with the reminders). I tried to add a new authorization method that fits with the later version. static func requestAccess() { let eventStore = EKEventStore() let todayDate : Date = Date() let status = EKEventStore.authorizationStatus(for: .event) if status == .authorized { print("Access is already granted.") } else { print(status.rawValue) eventStore.requestFullAccessToEvents { success, error in if success && error == nil { print("Access has been granted.") } else { print(error ?? "unknown error") print("Access request failed with error: \(error?.localizedDescription ?? "Unknown error")") } } } } NSCalendarsWriteOnlyAccessUsageDescriptionHowever, even though I have both the NSCalendarWriteOnlyAccessDescription, adn the older NSCalendarUsageDescription as shown here: But the watch app not only fails to show a message to the user requesting access to the events on the watch, when I try to see what is causing the problem (despite the plist clearly showing the message), all I get is this output: Does anyone know what is the problem, even though the plist clearly has descriptions. Thank you in advance.
Posted
by
Post not yet marked as solved
0 Replies
283 Views
I'm looking for a way to access the information about which Section a Reminder is in, and also create a Reminder in a specific Section. The sections feature was released in iOS 17 I believe: https://support.apple.com/en-am/guide/iphone/iph82596cb20/ios I don't see any mention of Sections in the EventKit documentation: https://developer.apple.com/documentation/eventkit I checked if each section is technically a Calendar but it doesn't appear so. Any guidance would be helpful.
Posted
by
Post not yet marked as solved
0 Replies
524 Views
Add to apple calendar is not working react PWA app on iPhone I have developed react PWA app reactjs - v16.14.0 and testing in my iphone13. I have used **npm library ** which opens google,outlook, apple calender event properly on android device, on IOS google and outlook works fine but add to apple calendar event doesnt not show any popup or not showing any error. I have reported one issue on this library forum but they have mentioned that Apple blocks the dynamic generation of ics files I am looking for resolution for this. Let me know proper way to add event in apple calender considering javascript library. [Edited by Moderator]
Posted
by
Post not yet marked as solved
2 Replies
351 Views
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'" formatter.calendar = Calendar.init(identifier: .gregorian) let strdate = formatter.string(from:Date()) let myDate = IMUtil.stringtoDateConverter(startDateString: strdate) formatter.dateFormat = "yyyyMMddHHmmss" guard let timeZone = NSTimeZone(name: "UTC") as TimeZone? else { return } formatter.timeZone = timeZone if startIndex == 0 { currentDate = formatter.string(from: myDate) } I'm using above code to create a date . Expected response : 20240104190840 Response : 14810104190840 Why is it giving wrong year?
Posted
by
Post not yet marked as solved
1 Replies
327 Views
When creating an all-day event in the iCloud Calendar web interface, the displayed end date appears as the next day. This is confusing and misleading for users as it does not accurately represent the event's 24-hour duration. Impact: Users are unsure of the actual end time of the event, potentially causing schedule conflicts or missed reminders. The visual representation of the event is inaccurate and can be frustrating for users accustomed to standard time-based formats. Suggestion: Display the full duration of the all-day event explicitly (e.g., "All-day, 24 hours") or adjust the end date representation to avoid confusion (e.g., "Ends on the same day").
Posted
by
Post not yet marked as solved
1 Replies
346 Views
when adding an event in iPhone calendar it is possible to add attachment. Properties of EKEvent do not include attachments. Is there a way to access programmatically using Swift?
Posted
by
Post not yet marked as solved
3 Replies
460 Views
My iOS app get access to Calendars on iPhone and iPad (iOS 17) bey when running on Mac (designed for iPad) the app gets the ".notDetermined" authorizationStatus after a call to EKEventStore.authorizationStatus(for: .event). What should I do so that my App gain access to Calendars ?
Posted
by
Post not yet marked as solved
0 Replies
334 Views
Others and I are having problems with our local offline USB synchronizing our calendars in the recent macOS versions (started in Ventura) and iP* devices as shown in these links: https://talk.tidbits.com/t/my-mac-apple-calendar-went-berserk-i-need-help/23878/39 https://discussions.apple.com/thread/254982807 https://discussions.apple.com/thread/254549186 https://discussions.apple.com/thread/254463571 https://discussions.apple.com/thread/254650642 https://discussions.apple.com/thread/254890299 https://discussions.apple.com/thread/254876661 etc. We reported this to Apple too with our bug reports, but nothing. We don't want to use clouds too. Thank you for reading and hopefully answering.
Posted
by
Post not yet marked as solved
2 Replies
456 Views
I want to find the "last Sunday of a month before the current date" in Swift, but using the Calendar nextDate function doesn't work (always returns nil). var calendar: Calendar = Calendar(identifier: .gregorian) calendar.timeZone = .gmt let lastSundayDateComponents: DateComponents = DateComponents( weekday: 1, weekdayOrdinal: -1 ) let previousLastSundayDate: Date? = calendar.nextDate( after: Date.now, matching: lastSundayDateComponents, matchingPolicy: .nextTime, repeatedTimePolicy: .first, direction: .backward ) print(previousLastSundayDate ?? "Not found") // "Not found" If I use a positive weekdayOrdinal, it's working normally and the same nextDate method provides the correct date. let firstSundayDateComponents: DateComponents = DateComponents( weekday: 1, weekdayOrdinal: 1 ) When I check if the date components can provide a valid date for the given calendar, it returns false... let lastSundayInNovember2023DateComponents: DateComponents = DateComponents( year: 2023, month: 11, weekday: 1, weekdayOrdinal: -1 ) // THIS RETURNS FALSE let isValid: Bool = lastSundayInNovember2023DateComponents.isValidDate(in: calendar) print(isValid) // false ... even if the correct date can be created. let lastSundayInNovember2023: Date = calendar.date(from: lastSundayInNovember2023DateComponents)! print(lastSundayInNovember2023) // 2023-11-26 00:00:00 +0000 Is that a bug in Foundation?
Posted
by
Post not yet marked as solved
0 Replies
464 Views
Hi, I am evaluating the write ony mode and on my Development iPhone (14 Max Pro / 17.2) I get an error when trying to add an event in write only access mode. I am using the provided snippet let store = EKEventStore() // Request write-only access guard try await store.requestWriteOnlyAccessToEvents() else { return } // Create an event let event = EKEvent(eventStore: store) event.calendar = store.defaultCalendarForNewEvents event.title = "WWDC23 Keynote" event.startDate = myEventStartDate event.endDate = myEventEndDate event.timeZone = TimeZone(identifier: "America/Los_Angeles") event.location = "1 Apple Park Way, Cupertino, CA, United States" event.notes = "Kick off an exhilarating week of technology and community." // Save the event guard try eventStore.save(event, span: .thisEvent) else { return } On the .save step I receive the following Error ("The calendar is read only") Failed to save event: Error Domain=EKErrorDomain Code=6 "Der Kalender ist schreibgeschützt." UserInfo={NSLocalizedDescription=Der Kalender ist schreibgeschützt.} Changing the premission to Full Access makes the snippet work. I tested with iCloud and CalDav Accounts. Both fail. Does anyone have similiar problems? Or a solution to this? It seems like a bug to me.
Posted
by
Post not yet marked as solved
1 Replies
297 Views
I want to create a list in the Reminders app using EventKit. For each created list, I want to create EKReminders. However, it seems that EventKit does not provide a way to create a reminder list directly. How can I achieve this?
Posted
by
Post not yet marked as solved
0 Replies
357 Views
I'm facing an issue with the XCode storyboard. It is not working properly. I wouldn't show any of my designs and when I click anywhere on it it shows the message " Loading Documents". After some time Xcode goes on not responding state. I have tried several things like reinstalling the Xcode, restarting the Mac, clearing cache, clearing derived data, and many more, but alas.
Posted
by
Post not yet marked as solved
0 Replies
352 Views
I use this function to read calendar headers in a array of strings: `func getCalendarHeaders(ofType: EKEntityType, alerter: Alerter) async -> [String] { var headers: [String] = [] do { if try await requestAuthorizationFor(ofType) { let calendars = try await fetchCalendars(ofType: ofType) for calendar in calendars { headers.append(calendar.title) } } } catch let error { DispatchQueue.main.async { alerter.alert = ErrorManager.shared.showAlert(error: error) } } return headers } In my view model / or view I try to init with: Task { self.eventCalendarHeaders = await CalendarManager.shared.getCalendarHeaders(ofType: EKEntityType.event, alerter: alerter) } Why I get this error? Trailing closure passed to parameter of type 'EKEvent?' that does not accept a closure
Posted
by
Post marked as solved
1 Replies
393 Views
Since updating to Sonoma and using XCode 15.0.1 to adapt my app's code base to deal with new requirement for Full Access to calendars, I am simply unable to find ANY valid calendars of type EKEntityTypeEvent despite having about 8 different EKSources available (which I can see and access in the macOS Calendar app), and which do contain calendars I used to be able to read/write to before I updated to Catalina. But the call to EKSource's calendarsForEntityType function always returns nil. I have successfully obtained Full Access permission (which in any case is obviously so because otherwise I would not get access to all the EKSource items). I've also rebooted several times. I have Calendar selected under Resource Access items for the app's capabilities. Does anyone have any idea why, or a workaround? Looks like a potentially serious bug at this point.
Posted
by
Post not yet marked as solved
1 Replies
390 Views
I'm trying to write a program where I want to get the text content selected by the mouse by detecting mouse movements. My main code is as follows: #import "AppDelegate.h" #import <Cocoa/Cocoa.h> @interface AppDelegate () @property (strong) IBOutlet NSWindow *window; @property (nonatomic) CFMachPortRef eventTap; @end CGEventRef myCGEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon) { if (type == kCGEventLeftMouseDown) { NSLog(@"Mouse down."); } else if (type == kCGEventLeftMouseUp) { NSLog(@"Mouse up."); NSRunningApplication *currentApp = [[NSWorkspace sharedWorkspace] frontmostApplication]; AXUIElementRef appElement = AXUIElementCreateApplication(currentApp.processIdentifier); AXUIElementRef windowElement; AXError error = AXUIElementCopyAttributeValue(appElement, kAXFocusedWindowAttribute, (CFTypeRef *)&windowElement); if (error != kAXErrorSuccess) { NSLog(@"Could not get focused window. Error code: %d", error); return event; } AXValueRef selectedTextValue; error = AXUIElementCopyAttributeValue(windowElement, kAXSelectedTextAttribute, (CFTypeRef *)&selectedTextValue); if (error != kAXErrorSuccess) { NSLog(@"Could not get selected text. Error code: %d", error); return event; } NSString *selectedText = (__bridge_transfer NSString *)selectedTextValue; NSLog(@"Selected text: %@", selectedText); } return event; } @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code here to initialize your application self.eventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, 0, CGEventMaskBit(kCGEventLeftMouseDown) | CGEventMaskBit(kCGEventLeftMouseUp), myCGEventCallback, NULL); if (self.eventTap) { CFRunLoopSourceRef runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, self.eventTap, 0); CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes); CGEventTapEnable(self.eventTap, true); CFRelease(runLoopSource); // Don't release eventTap here } else { NSLog(@"Failed to create event tap"); } } - (void)applicationWillTerminate:(NSNotification *)aNotification { // Insert code here to tear down your application if (self.eventTap) { CFRelease(self.eventTap); } } - (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app { return YES; } @end I confirmed that I have granted "Accessibility" permissions to my program and the application I am trying to access is xcode or when I try to access the chrome interface I get the same error kAXErrorCannotComplete. So how do I deal with this problem? Or is there any other way to achieve my target function? PS: I solved the above error by set App Sandbox Value (NO) in the entitlements, but I don't know if this is a reasonable solution. And then AXUIElementCopyAttributeValue generated another error kAXErrorFailure. How should I troubleshoot this problem ?
Posted
by