Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singleton pattern on EKEventStore instance #551

Open
AlexisChoupault opened this issue Aug 2, 2024 · 0 comments · May be fixed by #552
Open

Singleton pattern on EKEventStore instance #551

AlexisChoupault opened this issue Aug 2, 2024 · 0 comments · May be fixed by #552
Labels
enhancement New feature or request iOS

Comments

@AlexisChoupault
Copy link

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.

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 ?

Thank you

@AlexisChoupault AlexisChoupault added the enhancement New feature or request label Aug 2, 2024
@AlexisChoupault AlexisChoupault linked a pull request Aug 2, 2024 that will close this issue
@thomassth thomassth added the iOS label Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request iOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants