From 2efbd4481177456cd90c8020256924df950460cb Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 29 Apr 2019 09:29:57 -0500 Subject: [PATCH] Fix to stop background refresh when interval set to manually. --- iOS/AppDelegate.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/iOS/AppDelegate.swift b/iOS/AppDelegate.swift index 3c704d9f3..6f09fd21c 100644 --- a/iOS/AppDelegate.swift +++ b/iOS/AppDelegate.swift @@ -92,7 +92,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele } } - UIApplication.shared.setMinimumBackgroundFetchInterval(AppDefaults.refreshInterval.inSeconds()) + updateBackgroundRefreshInterval() return true @@ -222,7 +222,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele } @objc func userDefaultsDidChange(_ note: Notification) { - UIApplication.shared.setMinimumBackgroundFetchInterval(AppDefaults.refreshInterval.inSeconds()) + updateBackgroundRefreshInterval() } @objc func accountRefreshDidFinish(_ note: Notification) { @@ -244,6 +244,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele private extension AppDelegate { + func updateBackgroundRefreshInterval() { + let refreshInterval = AppDefaults.refreshInterval + if refreshInterval == .manually { + UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplication.backgroundFetchIntervalNever) + } else { + UIApplication.shared.setMinimumBackgroundFetchInterval(AppDefaults.refreshInterval.inSeconds()) + } + } + func sendReceivedArticlesUserNotification(newArticleCount: Int) { let content = UNMutableNotificationContent()