Try to register for remote notifications when feed inspector appears
This commit is contained in:
parent
927db2c375
commit
1123a0be86
@ -49,7 +49,11 @@ final class WebFeedInspectorViewController: NSViewController, Inspector {
|
|||||||
updateUI()
|
updateUI()
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(imageDidBecomeAvailable(_:)), name: .ImageDidBecomeAvailable, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(imageDidBecomeAvailable(_:)), name: .ImageDidBecomeAvailable, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func viewDidAppear() {
|
||||||
|
updateNotificationSettings()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Actions
|
// MARK: Actions
|
||||||
@IBAction func isNotifyAboutNewArticlesChanged(_ sender: Any) {
|
@IBAction func isNotifyAboutNewArticlesChanged(_ sender: Any) {
|
||||||
feed?.isNotifyAboutNewArticles = (isNotifyAboutNewArticlesCheckBox?.state ?? .off) == .on ? true : false
|
feed?.isNotifyAboutNewArticles = (isNotifyAboutNewArticlesCheckBox?.state ?? .off) == .on ? true : false
|
||||||
@ -135,7 +139,18 @@ private extension WebFeedInspectorViewController {
|
|||||||
func updateFeedURL() {
|
func updateFeedURL() {
|
||||||
urlTextField?.stringValue = feed?.url ?? ""
|
urlTextField?.stringValue = feed?.url ?? ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateNotificationSettings() {
|
||||||
|
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.userNotificationSettings = settings
|
||||||
|
if settings.authorizationStatus == .authorized {
|
||||||
|
NSApplication.shared.registerForRemoteNotifications()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func updateNotifyAboutNewArticles() {
|
func updateNotifyAboutNewArticles() {
|
||||||
isNotifyAboutNewArticlesCheckBox?.state = (feed?.isNotifyAboutNewArticles ?? false) ? .on : .off
|
isNotifyAboutNewArticlesCheckBox?.state = (feed?.isNotifyAboutNewArticles ?? false) ? .on : .off
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user