I'm using device_calendar through a singleton custom class CalendarService and I've been experiencing issues on iOS 17 lately.
Every time I wait a few seconds before approving calendar permission, the latter seems not to be taken into account until I restart my app.
INVOKE_CHANNEL_METHOD_ERROR: PlatformException(401, The user has not allowed this application to modify their calendar(s), null, null)
I went through EventKit documentation and I saw that EKEventStore instances should be long-lived : created and destroyed as little as possible during the lifetime of an application instance. So I tried implementing the Singleton pattern on our EKEventStore instance and it solved my problem. Which does not make much sense to me as I've got the same instance of DeviceCalendarPlugin everywhere in my app, so the instance of EKEventStore is the same.
# instance printed before requesting permission
flutter: <EKEventStore: 0x7febac45e680>
# instance printed after permission and before retrieving calendars
flutter: <EKEventStore: 0x7febac45e680>
I don't understand why it behaves this way. My only guess is that the static method EKEventStore.authorizationStatus(for: .event) does not catch up fast enough after eventStore request is approved, but it would be weird.
If anyone has a clue, I'd love to hear from you.
Should we make the EKEventStore instance a singleton ?
Hello,
I'm using device_calendar through a singleton custom class CalendarService and I've been experiencing issues on iOS 17 lately. Every time I wait a few seconds before approving calendar permission, the latter seems not to be taken into account until I restart my app.
I went through EventKit documentation and I saw that EKEventStore instances should be long-lived : created and destroyed as little as possible during the lifetime of an application instance. So I tried implementing the Singleton pattern on our EKEventStore instance and it solved my problem. Which does not make much sense to me as I've got the same instance of DeviceCalendarPlugin everywhere in my app, so the instance of EKEventStore is the same.
I don't understand why it behaves this way. My only guess is that the static method
EKEventStore.authorizationStatus(for: .event)
does not catch up fast enough after eventStore request is approved, but it would be weird. If anyone has a clue, I'd love to hear from you.Should we make the EKEventStore instance a singleton ?
Thank you