According to the Apple Developer Documentation:
An EKEventStore object posts an EKEventStoreChanged notification whenever it detects changes to the Calendar database
The article then goes on to provide examples of how to do this in UIKit:
NotificationCenter.default.addObserver(self, selector: Selector("storeChanged:"), name: .EKEventStoreChanged, object: eventStore)
In SwiftUI, I tried to do it this way:
let publisher = NotificationCenter.default.publisher(for: NSNotification.Name("EKEventStoreChanged"))
and
.onReceive(publisher) { value in
print("Store Changed")
}
But I never received any notification, and therefore the print statement was never called.
I also tried this:
let publisher = NotificationCenter.default.publisher(for: NSNotification.Name.EKEventStoreChanged)
but nothing changed.
My Question: How do I receive the EKEventStoreChanged notification in SwiftUI?
Any help would be appreciated.