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

59 Posts
Sort by:
Post not yet marked as solved
1 Replies
675 Views
when i use FirebaseFirestore in flutter app i got below error so plz guide to me. [!] The 'Pods-Runner' target has transitive dependencies that include statically linked binaries: (FirebaseFirestore)
Posted
by
Post marked as solved
1 Replies
414 Views
Hi, I'm creating a calendar application. I am using the EKeventEditViewController to add events to my application. The problem is that the title of the sheet cannot be modified. When I change a title, the console shows that the title has changed. However, the simulator still displays the previous title; "New Event". How can I fix it? void (^showEventEditingController)(EKEvent *) = ^(EKEvent * event){ EKEventEditViewController *controller = [[EKEventEditViewController alloc] init]; controller.event = event; controller.eventStore = [self getEventStoreInstance]; controller.editViewDelegate = self; NSLog(@"%@", controller.title); // "New Event" controller.title = @"My Custom title"; NSLog(@"%@", controller.title); // "My Custom title" [self assignNavbarColorsTo:controller.navigationBar]; [self presentViewController:controller]; NSLog(@"%@", controller.title); // "My Custom title" };
Posted
by
Post not yet marked as solved
0 Replies
467 Views
How do I access the user's reminders on Vision Pro? When I use the same code from iOS with EventKit, the reminders and reminder lists are empty. Is the way to access reminders the same on VisionOS as it is on iOS, iPadOS, and macOS? Or is there a new framework? Thanks.
Posted
by
Post not yet marked as solved
0 Replies
562 Views
So I'm looking to add a button to my app that would create and fill a reminder in the user's Reminders app, but I've found that I first need to request access to the user's Reminders app data. I've also found the way to do that has been changed with iOS 17 as explained here: https://developer.apple.com/documentation/eventkit/ekeventstore/4162273-requestfullaccesstoreminders How do I use this function so that the prompt requesting for access to the user's Reminders app pops up at the launch of the app every time unless they've previously given permission? Also what would be the function to create the reminder once I do have permissions? This is the code ChatGPT gave me to do so, but I just keep getting "Failed to create Reminder URL". func createReminder() { let reminderTitle = "******** Groceries" var subtaskStrings: [String] = [] for ingredient in shoppingList { subtaskStrings.append(ingredient) } let subtasks = subtaskStrings.map { (ingredient) -> [String: Any] in return [ "title": ingredient, "completed": false ] } let reminderData: [String: Any] = [ "title": reminderTitle, "subtasks": subtasks ] if let reminderURL = createURL(for: "x-apple-reminder://", with: reminderData) { UIApplication.shared.open(reminderURL) } else { print("Failed to create Reminder URL") } } Also I intend on expanding this function to the notes app. But im taking one step at a time. Any help would be GREATLY appreciated. Thanks!
Posted
by
Post not yet marked as solved
0 Replies
372 Views
I've created an event in icloud calendar in Iranian TimeZone. In the detials the TimeZone is appearing as Iraninan Standard Time - UTC +3:30. From the Developer's API we are getting the TImeZone as UTC+4:30. Please check and get back to us. Thanks, Ashu
Posted
by
Post not yet marked as solved
0 Replies
526 Views
I have an app that has lots of booking dates. I need a quick way to open the Mac Calendar on the date of the booking just so the user can cross check the dates for clashes. At this stage, I don't need to build UI into my app that shows the dates. What is already in Calendar is sufficient - don't reinvent the wheel. A long time ago, calshow seemed to be the way to do this. But that seems to have withered away. Opening a URL with ical:// opens calendar, but not at the date required since there seems to be no URL scheme defined. I could query Event Kit, but that means building unnecessary UI at this time. There's possibly a way to do this with Scripting Bridge and probably a way to do this with a call to an AppleScript. Is there no simpler way to do this in 2023 on a Mac?
Posted
by
Post not yet marked as solved
1 Replies
393 Views
It looks like the delegate function eventEditViewControllerDefaultCalendar(forNewEvents controller: EKEventEditViewController) -> EKCalendar of the EKEventEditViewDelegate protocol is not called in iOS 17 anymore. The app does have the new NSCalendarsFullAccessUsageDescription key set and full access is granted. Is this the intended behaviour for iOS 17? Does anybody else have the same problem?
Posted
by
Post not yet marked as solved
0 Replies
327 Views
Hello everyone, I'm attempting to incorporate a button in my StartView that will lead directly to ContentView without the intermediate step of using a navigation view. I want StartView to seamlessly transition into ContentView. Thank you very much in advance! import SwiftUI struct StartView: View { @State private var isQuizStarted = false @Environment(.presentationMode) var presentationMode var body: some View { VStack { Text("Radiology Core Prep Q&A") .font(.headline) .padding() Image("cxr") .resizable() .aspectRatio(contentMode: .fit) .frame(height: 325) } } } struct StartView_Previews: PreviewProvider { static var previews: some View { StartView() } }
Posted
by
Post not yet marked as solved
1 Replies
422 Views
iPad Pro 12.9 、iOS15.4 (21E230) #700003 NSInternalInconsistencyException -[UINSUIKitBackgroundingController _updateAppWideBackgroundStateSlammingNotifyingDelegate:]: Called off the main thread. CoreFoundation __exceptionPreprocess CoreFoundation __exceptionPreprocess + 220 2 Foundation -[NSCalendarDate initWithCoder:] + 0 3 UIKitMacHelper -[UINSUIKitBackgroundingController _updateAppWideBackgroundStateSlammingNotifyingDelegate:] + 504 4 UIKitMacHelper -[UINSUIKitBackgroundingController transitionUIAppThroughBackgroundStateIfNecessary] + 144 5 UIKitMacHelper -[UINSApplicationLifecycleController transitionAppThroughBackgroundState] + 308 6 UIKitMacHelper -[UINSApplicationDelegate _toggleAppForegroundStateIfAppStoreURL:] + 276 7 UIKitMacHelper __54-[UINSApplicationDelegate openURL:options:completion:]_block_invoke_2 + 196 8 AppKit _NSWorkspaceHandleLSOpenResult + 164 9 LaunchServices _LSFireCompletionHandler(void (__LSASN const*, unsigned char, __CFError*) block_pointer, NSURL*, NSURL*, NSDictionary<NSString*, objc_object*>, objc_object, bool, NSError*) + 200 10 LaunchServices _LSOpenAsyncCommonDispatched(objc_object*, NSArray<NSURL*>, NSURL, objc_object*, NSDictionary<NSString*, objc_object*>, NSObject<OS_dispatch_semaphore>, void (__LSASN const*, unsigned char, __CFError*) block_pointer) + 5732 11 libdispatch.dylib _dispatch_call_block_and_release + 32 17 libsystem_pthread.dylib start_wqthread + 8 #0 Thread 0 libsystem_kernel.dylib mach_msg_trap + 8 4 CoreFoundation CFRunLoopRunSpecific + 600 5 HIToolbox RunCurrentEventLoopInMode + 292 6 HIToolbox ReceiveNextEventCommon + 564 7 HIToolbox _BlockUntilNextEventMatchingListInModeWithFilter + 72 8 AppKit _DPSNextEvent + 860 9 AppKit -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1328 10 AppKit -[NSApplication run] + 596 11 AppKit NSApplicationMain + 1132 12 AppKit +[NSWindow _savedFrameFromString:] + 0 13 UIKitMacHelper UINSApplicationMain + 1276
Posted
by
Post not yet marked as solved
3 Replies
1k Views
Hi, I am facing a problem related to the API in the title. When the API is executed with EKAuthorizationStatus notDetermined, the dialog is not displayed and (false, nil) is passed to completion. // Create an event store let store = EKEventStore() store.requestWriteOnlyAccessToEvents { granted, error in if let error { print("error occurred") } else if granted { print("allowed") } else { print("denied") } } // "denied" That is why I am not sure what is causing the dialog not to appear. Is this a bug in the API? note This is not a problem in the simulator. It is a problem **only on the actual device. development environment Xcode Version 15.0 (15A240d) iPhone SE(3rd) iOS 17.0.2 (21A351)
Posted
by
Post not yet marked as solved
0 Replies
386 Views
Hello, I've implemented my Virtual conference extension and my app shows up without issues in the Calendar app and displays our app with a Join button and it all works great!. However, when creating an event from the main target of the app using EventKitUI with the help of EKEventEditViewController and an EKEvent instance, the event does not display as if it were a virtual conference. I see a few other apps like Zoom have implemented this and I'm having trouble finding the related documents on how to link a programtically created event with a virtual conference. Any help or pointers on how to achieve this is highly appreciated. Thanks!
Posted
by
Post not yet marked as solved
2 Replies
1.1k Views
I have experienced a strange issue on my iphone test device. (iPhone Xr running iOS 17.0.3) In my app I ask a user for calendar full access. Once I gave the access permission, the app works as expected. Then somehow the status changed from .fullAccess to .denied. This happens without my interaction in iPhone's Settings. I have doubled checked in Settings app and the permission is still granted. But somehow the status is denied when calling EKEventStore.authorizationStatus(for: .reminder) Regardless of how bad my code is, the app should not be able to change status from .fullAccess to .denied. Correct? I have never had this problem until lately. But it happens to both my iOS app and my mac Catalyst app. Which is really strange. (iOS 17.0.3 and Sonoma 14.0) This problem doesn't happen all the time though. Most of the time my app works fine. But it can happen few times per day. And even more strange, it tends to happen at the same time for iOS and macOS. I don't know if this problem happens to me because of the fact that I install/uninstall the app many times but currently it just causes me a headache. I have attached 2 images. These 2 images happen at the same time. The only fix is that I have to turn off then turn on the Full Access again in Settings app. Something for Reminder. Any advice is much appreciated. Thank you.
Posted
by
Post not yet marked as solved
0 Replies
285 Views
Hello, I try to read reminders in my app using Swift and the EventKit API. This works great with one exception: the url field. It is clearly set for a reminder and the official reminders app displays the link correctly . In my Swift code I get the reminder object and title, notes, etc are correctly set. The attribute URL is always nil and I couldn't find any other matching attribute. Has anybody solved this? I use fetchReminder on the EKEventStore to retrieve the reminders. This should result in EKCalendarItem objects. I use the snippet below to access the reminders and it works for all attributes except the url attribute. let jsonElements = reminders.enumerated().map({JsonReminder(id: $1.calendarItemIdentifier, title: $1.title, notes: $1.notes, completed: $1.isCompleted, dateString: createDateString(date: $1.dueDateComponents), url: createUrlString(url: $1.url))}) Kind regards Dominik
Posted
by
Post not yet marked as solved
1 Replies
415 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
Post marked as solved
1 Replies
410 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
0 Replies
373 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 not yet marked as solved
0 Replies
383 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
1 Replies
324 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
493 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