I'm building a macOS app that (among other things) sends notifications. In the app settings (right) I'm showing the current notification permission. If the access is not granted, I offer the option to open the system preferences. I want my app to reflect permission changes the user makes in the system preferences immediately to provide good feedback in the UI.
Is there a way to be notified when the user performs changes to my apps notification permissions?
I've done some research but the solution I could find involves observing NSApplication.didBecomeActiveNotification
, but that's not what I want. This way the app will only update once it gets activated again (when some action is performed) but I want to be notified immediately and using the NSApplication.didBecomeActiveNotification
observer triggers every time the app becomes active, not just when settings change (leads to many unnecessary calls). Here's my code:
NotificationCenter.default.addObserver(self, selector: #selector(checkNotificationStatus), name: NSApplication.didBecomeActiveNotification, object: nil)
I've also found this answer but its basically using the same method.
Does somebody have an idea how to accomplish that? I wish there was sth. like NSApplication.didChangeSettingsNotification
:D
Thank you in advance!