Open iamandreadompe opened 2 weeks ago
@ebarooni Looks like the EKSource has to be specified. This isn't the exact code, just what ChatGPT suggested.
func createCalendar(eventStore: EKEventStore) {
guard let iCloudSource = eventStore.sources.first(where: { $0.sourceType == .calDAV && $0.title == "iCloud" }) else {
print("iCloud source not found")
return
}
let calendar = EKCalendar(for: .event, eventStore: eventStore)
calendar.title = "My iCloud Calendar"
// Instead of eventSource.defaultCalendarForNewEvents?.source
calendar.source = iCloudSource
do {
try eventStore.saveCalendar(calendar, commit: true)
print("Calendar created successfully")
} catch {
print("Error creating calendar: \(error.localizedDescription)")
}
}
Note that if the user is not signed into iCloud, the .sourceType may be .local.
Thanks @iamandreadompe and @aparajita for the clarifications. I will include this for the next release.
Hello to everyone!
i'm trying to create a new calendar on my iPhone
i do this
const permissionResults = await CapacitorCalendar.requestAllPermissions();
Permission results {"readCalendar":"granted","writeReminders":"granted","readReminders":"granted","writeCalendar":"granted"}
i get this error
UPDATE
I didn't have any calendars on my iphone, i've just few calendars with google calendars, so i've tried to create manually a new calendar "Test" and in the Calendars Options inside iphone i set "TEST" as the default calendar (create manually on iPhone) now i can create all the calendars i want....
i think there is a sort of default calendar system, i think before with the google as default calendar the plugin was trying to create the calendar on Google, because a calendar I had on Google was set as the default calendar.
How can we prevent this situation?
If by chance a user is in the same situation as me, i.e. with the default calendar on Google are we screwed?