I’m building an app that allows the user to add and create events in the Calendar native app for iPhone.
One of the features I’m working on is also to allow the user to add and create items in the Reminder’s native app of the iPhone.
From what I’ve read, the Calendar and Reminders app work with EventKit, and from the documentation, the process of each don’t differ too much.
I’m using this code to request permission to access Reminders and the code I use to add the items to the app.
Any thoughts on why is it not working?
Thanks in advance.
import Foundation
import EventKit
class EventModel {
let eventStore = EKEventStore()
func requestAccessForReminders() {
let status = EKEventStore.authorizationStatus(for: .reminder)
if status == .authorized {
print("EKEventStore access for Reminders already granted.")
} else {
eventStore.requestFullAccessToEvents { success, error in
if success && error == nil {
print("EKEventStore access for Reminders has been granted.")
} else {
print("EKEventStore access for Reminders request failed with error: \(error?.localizedDescription ?? "Unknown error")")
}
}
}
}
func addEventToReminders(title: String, startHour: Int, startMinute: Int, duration: Int) -> Void {
let newEvent = EKReminder(eventStore: self.eventStore)
newEvent.title = title
newEvent.calendar = self.eventStore.defaultCalendarForNewReminders()
do {
try eventStore.save(newEvent,
commit: true)
} catch let error {
print("Reminder failed with error \(error.localizedDescription)")
}
}
}
This is the information I have in the info.plist. (I know is the same message, but that shouldn’t be the main cause am I right?)





