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

Refresh events when app is reopened/brought to foreground #7

Closed
skegget opened this issue Dec 19, 2020 · 12 comments
Closed

Refresh events when app is reopened/brought to foreground #7

skegget opened this issue Dec 19, 2020 · 12 comments

Comments

@skegget
Copy link

skegget commented Dec 19, 2020

I'm fairly new to Swift and I've been using some of your EKEventKit examples (great work!) in a small project of mine. I've noticed one thing though. If you exit the app and make some changes to an event in the calendar app (like changing the name), the events fetched by your example are not updated. I can get the events to update by force closing the app or by reselecting the calendar(s).

Would it be possible to extend the example so it also updates the events when the app re-opened/brought back to foreground? Maybe by e.g. .willEnterForegroundNotification, or some other solution?

@nemecek-filip
Copy link
Owner

Hi, happy this repo was useful to you. I will add the update example :-)

@nemecek-filip
Copy link
Owner

Turns out, there is EventKit notification for this purpose :-) Let me know if it works as expected

@skegget
Copy link
Author

skegget commented Dec 19, 2020

Fantastic, thank you! I haven't had the time to test it yet. Just a thought though, are the changes also applicable to the SwiftUI version of your example?

@nemecek-filip
Copy link
Owner

Yes, I think it should work roughly in the same way. Subscribe to the EventKit notification and when you get it, reload all the events.

@skegget
Copy link
Author

skegget commented Dec 20, 2020

I gave it a try (or more like 50) but I can't seem to get it to work. And to be honest, this is way above my competence level. Would you mind updating the SwiftUI example as well? I would really appreciate it!

Thanks!

@nemecek-filip
Copy link
Owner

I can certainly try, but I am not really proficient with SwiftUI

@skegget
Copy link
Author

skegget commented Dec 20, 2020

That would be great! I came across this when searching for some examples:

https://developer.apple.com/documentation/foundation/nsnotification/name/1507525-ekeventstorechanged

@nemecek-filip
Copy link
Owner

Yes, that is what I used in UIKit version and now moved to SwiftUI. Although the whole SwiftUI version looks kind of broken right now after the iOS 14 update.. it should still work though

@skegget
Copy link
Author

skegget commented Dec 20, 2020

Ah, I see! Anyway, many thanks! I will give it a try and get back to you.

@nemecek-filip
Copy link
Owner

Closing for inactivity. Feel free to open fresh issue. Thanks.

@skegget
Copy link
Author

skegget commented Jan 3, 2021

Oh, sorry for not getting back to you, totally forgot about it. Anyway, your change works great! Good work!

@nemecek-filip
Copy link
Owner

No problem! Glad it works :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants