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.

Posts under EventKit tag

27 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

EventKit refreshSourcesIfNecessary() not triggering real-time sync with Google Calendar events
I'm working on an app that uses EventKit to access calendar events. For users with external calendars like Google Calendar, they can sync these by adding the account through iOS Calendar settings. Once added, the events appear in my app as expected. However, if a user adds a new event in Google Calendar, there’s often a delay before it appears in my app, since the iOS Calendar doesn't sync with external sources like Google in real time. Currently, users can manually trigger a sync by opening the Apple Calendar app and using the pull-to-refresh feature under the "Calendars" tab. This works reliably but isn’t an ideal solution. I tried using the EventKit method refreshSourcesIfNecessary() to minimize the delay, as it claims to "[Pull] new data from remote sources, if necessary" (link to docs). I trigger this method when the app returns to the foreground. But, I'm not seeing the expected results. Here’s a typical sequence: Open my app and send it to the background. Add an event in Google Calendar. Return to my app. Despite invoking refreshSourcesIfNecessary(), the new event doesn’t appear in Apple Calendar (or accordingly in my app), until some random delay (30 seconds to several minutes). In contrast, the Apple Calendar app’s pull-to-refresh fetches the event immediately, every time. Am I misinterpreting how refreshSourcesIfNecessary() is intended to work? Or is there another way to achieve a faster sync with external calendars?
0
0
99
3w
EKEventStore unable to save events
I have a feature where I need to write some events to the calendar. It's not working saying Calendar is read only. So I tried the sample app from Apple - Repeating lessions and drop in lessions from link below https://developer.apple.com/documentation/eventkit/accessing_calendar_using_eventkit_and_eventkitui Drop in sessions which uses EKEventEditViewController works fine. But when I run Repeating lessions which requires calendar permissions it keeps saying Calendar is read only. I have hit allow on the access permissions alert and also check settings which shows app has required permissions. can someone help why this is the case? if its a Calendar issue where do you set the modifiable permissions for it? How is EKEventEditViewController able to save events if the Calendar is readonly.
1
0
168
Oct ’24
Array<NSNumber> not working for EKRecurringRule in EventKit
I am having an issue here with the NSNumber Type using with SwiftUI and I am not sure what I am doing wrong here? @State private var recurringMonthsTest: NSNumber = 1` let rule = EKRecurrenceRule( recurrenceWith: recurringOn, interval: recurringInterval, daysOfTheWeek: [EKRecurrenceDayOfWeek.init(EKWeekday.monday)], daysOfTheMonth: [], monthsOfTheYear: [recurringMonthsTest], weeksOfTheYear: [], daysOfTheYear: [], setPositions: nil, end: EKRecurrenceEnd.init(occurrenceCount: 8)) } Here is some basic Code to explain the issue, if you look at the above code it works well, I can also put 2 or more NSNumber single values inside the rule. But if I start to use the Array as below let recurringMonthsTest2: Array<NSNumber> = [recurringMonthsTest, recurringMonthsTest1] let rule = EKRecurrenceRule( recurrenceWith: recurringOn, interval: recurringInterval, daysOfTheWeek: [EKRecurrenceDayOfWeek.init(EKWeekday.monday)], daysOfTheMonth: [], monthsOfTheYear: [recurringMonthsTest2], weeksOfTheYear: [], daysOfTheYear: [], setPositions: nil, end: EKRecurrenceEnd.init(occurrenceCount: 8)) } It doesn't compile and I get the below error which I don't understand. `Cannot convert value of type 'Array' to expected element type 'Array.ArrayLiteralElement' (aka 'NSNumber') As I understand both are of the same value but why they don't compile? I tried already several versions like [NSNumber] = [] but everything is failing... What am I doing wrong here, can anyone help?
1
0
337
Aug ’24
How to open Calendar app event's detail by its ID
Hey there, I'd like to ask for guidance on how to open the Apple Calendar app's event programmatically. I can already list events, but I'm struggling to open the calendar detail view (upon user interaction). I've tried many variants, such as using the x-apple-calevent URL scheme or calshow:\, etc., but none of them worked. Here's the code I'm using: if let eventIdentifier = event.eventIdentifier as String?, let calendarId = event.calendarId as String? { if let url = URL(string: "x-apple-calevent://\(calendarId)/\(eventIdentifier)") { NSWorkspace.shared.open(url) } } Once the action is triggered, it tells me that: There is no application set to open the URL x-apple-calevent://909114A0-6352-47DB-B70E-2770H7D5B6D3:7q50iih7fvbio3qipk5m7osjig@google.com Thanks a bunch! Tom
1
0
581
Jul ’24
Event Message Error Undocumented.
I am getting a lot of messages of the nature that follows; "RoomPlanExampleApp[606:114689] [ClientDonation] (+[PPSClientDonation sendEventWithIdentifier:payload:]) Invalid inputs: payload={ aneModelPath = "/System/Library/PrivateFrameworks/ObjectUnderstanding.framework/PrecompiledModels/od_af_online.bundle/H14G.bundle/main/main_ane/model.hwx"; bundleIdentfier = "com.example.apple-samplecode.RoomPlanExampleApp9QSS565686"; }" WHAT is the component origin of the message? What can be done to remedy it? This is another example of an error message that does not have enough information for the developer to take remedial action.
1
1
497
Jun ’24
"Join" button next to video conference meeting URL in iOS/macOS native calendar
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
0
0
536
Feb ’24
Permission issue accessing Reminders through EventKit in MacOS app
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!
1
0
698
Feb ’24
EKEventStore on Apple Watch not showing all calendars
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() } }
0
0
567
Jan ’24
Issue with Calendar Access
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.
0
0
698
Jan ’24
Programmatically create Reminder in specific Section of a List
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.
0
0
533
Jan ’24
Add to apple calendar is not working react PWA app on iPhone
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]
0
0
895
Jan ’24
Date format giving wrong year
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?
2
0
598
Jan ’24
icalendar on a web browser has issues with all-day long events
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").
1
1
556
Jan ’24
Is there a known issue with macOS Finder's local USB file sync?
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.
0
0
570
Dec ’23