diff --git a/iOS/Settings/NotificationsViewController.swift b/iOS/Settings/NotificationsViewController.swift
index 9d8b79c70..f72e76567 100644
--- a/iOS/Settings/NotificationsViewController.swift
+++ b/iOS/Settings/NotificationsViewController.swift
@@ -18,12 +18,14 @@ class NotificationsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
- self.title = NSLocalizedString("Notifications", comment: "Notifications")
+ self.title = NSLocalizedString("New Article Notifications", comment: "Notifications")
notificationsTableView.sectionHeaderTopPadding = 25
NotificationCenter.default.addObserver(self, selector: #selector(reloadNotificationTableView(_:)), name: .FaviconDidBecomeAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(reloadNotificationTableView(_:)), name: .WebFeedIconDidBecomeAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(reloadNotificationTableView(_:)), name: .NotificationPreferencesDidUpdate, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(reloadNotificationTableView(_:)), name: UIScene.willEnterForegroundNotification, object: nil)
+
reloadNotificationTableView()
}
@@ -37,8 +39,6 @@ class NotificationsViewController: UIViewController {
}
}
-
-
private func sortedWebFeedsForAccount(_ account: Account) -> [WebFeed] {
return Array(account.flattenedWebFeeds()).sorted(by: { $0.nameForDisplay.caseInsensitiveCompare($1.nameForDisplay) == .orderedAscending })
}
@@ -49,33 +49,36 @@ class NotificationsViewController: UIViewController {
extension NotificationsViewController: UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
- /// 1 section for enabling notifications
- /// + number of active accounts
+ if status == .denied { return 1 }
return 1 + AccountManager.shared.activeAccounts.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- if section == 0 { return 1 }
+ if section == 0 {
+ if status == .denied { return 1 }
+ return 0
+ }
return AccountManager.shared.sortedActiveAccounts[section - 1].flattenedWebFeeds().count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "NotificationsCell") as! NotificationsTableViewCell
+
if indexPath.section == 0 {
- cell.configure(status)
+ let openSettingsCell = tableView.dequeueReusableCell(withIdentifier: "OpenSettingsCell") as! VibrantBasicTableViewCell
+ return openSettingsCell
} else {
+ let cell = tableView.dequeueReusableCell(withIdentifier: "NotificationsCell") as! NotificationsTableViewCell
let account = AccountManager.shared.sortedActiveAccounts[indexPath.section - 1]
let feed = sortedWebFeedsForAccount(account)[indexPath.row]
cell.configure(feed, status)
+ return cell
}
-
- return cell
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
- if section == 0 { return " " }
+ if section == 0 { return nil }
return AccountManager.shared.sortedActiveAccounts[section - 1].nameForDisplay
}
@@ -84,9 +87,6 @@ extension NotificationsViewController: UITableViewDataSource {
if status == .denied {
return NSLocalizedString("Notification permissions are currently denied. Enable notifications in the Settings app.", comment: "Notifications denied.")
}
- if status == .notDetermined {
- return NSLocalizedString("Turn on notifications to configure new article notifications.", comment: "Notifications not determined.")
- }
}
return nil
}
@@ -94,7 +94,10 @@ extension NotificationsViewController: UITableViewDataSource {
extension NotificationsViewController: UITableViewDelegate {
-
+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+ tableView.deselectRow(at: indexPath, animated: true)
+ UIApplication.shared.open(URL(string: "\(UIApplication.openSettingsURLString)")!)
+ }
}
diff --git a/iOS/Settings/Settings.storyboard b/iOS/Settings/Settings.storyboard
index 6e1653a0d..385a825db 100644
--- a/iOS/Settings/Settings.storyboard
+++ b/iOS/Settings/Settings.storyboard
@@ -1115,32 +1115,32 @@
-
+
-
+
-
+
-
+
-
+
@@ -1164,6 +1164,23 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/iOS/Settings/SettingsViewController.swift b/iOS/Settings/SettingsViewController.swift
index 77a42f303..ef845f19e 100644
--- a/iOS/Settings/SettingsViewController.swift
+++ b/iOS/Settings/SettingsViewController.swift
@@ -12,6 +12,7 @@ import CoreServices
import SafariServices
import SwiftUI
import UniformTypeIdentifiers
+import UserNotifications
class SettingsViewController: UITableViewController {
@@ -29,6 +30,8 @@ class SettingsViewController: UITableViewController {
var scrollToArticlesSection = false
weak var presentingParentController: UIViewController?
+ var notificationStatus: UNAuthorizationStatus = .notDetermined
+
override func viewDidLoad() {
// This hack mostly works around a bug in static tables with dynamic type. See: https://spin.atomicobject.com/2018/10/15/dynamic-type-static-uitableview/
NotificationCenter.default.removeObserver(tableView!, name: UIContentSizeCategory.didChangeNotification, object: nil)
@@ -38,6 +41,7 @@ class SettingsViewController: UITableViewController {
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange), name: .UserDidDeleteAccount, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange), name: .DisplayNameDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(activeExtensionPointsDidChange), name: .ActiveExtensionPointsDidChange, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(refreshNotificationStatus(_:)), name: UIScene.willEnterForegroundNotification, object: nil)
tableView.register(UINib(nibName: "SettingsComboTableViewCell", bundle: nil), forCellReuseIdentifier: "SettingsComboTableViewCell")
@@ -84,9 +88,7 @@ class SettingsViewController: UITableViewController {
}
colorPaletteDetailLabel.text = String(describing: AppDefaults.userInterfaceColorPalette)
-
openLinksInNetNewsWire.isOn = !AppDefaults.shared.useSystemBrowser
-
let buildLabel = NonIntrinsicLabel(frame: CGRect(x: 32.0, y: 0.0, width: 0.0, height: 0.0))
buildLabel.font = UIFont.systemFont(ofSize: 11.0)
@@ -110,7 +112,17 @@ class SettingsViewController: UITableViewController {
tableView.scrollToRow(at: IndexPath(row: 0, section: 4), at: .top, animated: true)
scrollToArticlesSection = false
}
-
+ refreshNotificationStatus()
+ }
+
+ @objc
+ func refreshNotificationStatus(_ sender: Any? = nil) {
+ UNUserNotificationCenter.current().getNotificationSettings { settings in
+ DispatchQueue.main.async {
+ self.notificationStatus = settings.authorizationStatus
+ self.tableView.reloadData()
+ }
+ }
}
// MARK: UITableView
@@ -118,6 +130,9 @@ class SettingsViewController: UITableViewController {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
+ case 0:
+ if notificationStatus == .authorized { return 2 }
+ return 1
case 1:
return AccountManager.shared.accounts.count + 1
case 2: