Open thiszhong opened 4 years ago
Seems to be the iCloud. When I close it by setting-account-iCloud-Calendar, createCalendar successed. Is there any solution?
are you guys gonna release the fix for this anytime soon ?
hi, guys, any updates for this issue?
+100 in favour of a fix for this
Has anyone come up with a way to handle this?
So I have zero experience or understanding of Swift so don't use this without checking it and testing it, but I adapted https://nemecek.be/blog/45/how-to-create-new-calendar-using-eventkit-in-swift to solve this problem and it seems to work for me.
Replace createCalendar() in SwiftDeviceCalendarPlugin.swift with:
private func createCalendar(_ call: FlutterMethodCall, _ result: FlutterResult) {
do {
let arguments = call.arguments as! Dictionary<String, AnyObject>
let calendar = EKCalendar(for: .event, eventStore: eventStore)
calendar.title = arguments[calendarNameArgument] as! String
calendar.cgColor = UIColor.purple.cgColor
let `default` = eventStore.defaultCalendarForNewEvents?.source
let iCloud = eventStore.sources.first(where: { $0.title == "iCloud" }) // this is fragile, user can rename the source
let local = eventStore.sources.first(where: { $0.sourceType == .local })
let source = iCloud ?? `default` ?? local
if (source != nil) {
calendar.source = source
try! eventStore.saveCalendar(calendar, commit: true)
result(calendar.calendarIdentifier)
} else {
result(FlutterError(code: self.genericError, message: "Local calendar was not found.", details: nil))
}
} catch {
eventStore.reset()
result(FlutterError(code: self.genericError, message: error.localizedDescription, details: nil))
}
}
If somebody takes a look at it, I'd be glad to submit a PR.
EDIT: Oops, I didn't do color setting. will do this later and update.
any solution found so far?
The post above seems to solve things
But I don't have xcode on my hand, so I can't make the PR on my own and test it
If anyone wants to submit said PR I would check it asap
It occurs on my real iPhone device(iPhone 7, iOS 13.3.1 et.), while simulator and android are OK. I tried both my app and the demo.