Prechádzať zdrojové kódy

Merge pull request #1530 from deltachat/retry_notification_service

Retry notification service
cyBerta 3 rokov pred
rodič
commit
e1cf2a60e7

+ 7 - 1
deltachat-ios/AppDelegate.swift

@@ -117,7 +117,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             // Reachability::reachabilityChanged uses DispatchQueue.main.async only
             logger.info("network: reachable", reachability.connection.description)
             DispatchQueue.global(qos: .background).async { [weak self] in
-                self?.dcAccounts.maybeNetwork()
+                guard let self = self else { return }
+                self.dcAccounts.maybeNetwork()
+                if self.notifyToken == nil &&
+                    self.dcAccounts.getSelected().isConfigured() &&
+                    !UserDefaults.standard.bool(forKey: "notifications_disabled") {
+                        self.registerForNotifications()
+                }
             }
         }
 

+ 2 - 1
deltachat-ios/Controller/ConnectivityViewController.swift

@@ -43,6 +43,7 @@ class ConnectivityViewController: WebViewViewController {
 
     // this method needs to be run from a background thread
     private func getNotificationStatus(hasNotifyToken: Bool, backgroundRefreshStatus: UIBackgroundRefreshStatus) -> String {
+        let connectiviy = self.dcContext.getConnectivity()
         let title = " <b>" + String.localized("pref_notifications") + ":</b> "
         let notificationsEnabledInDC = !UserDefaults.standard.bool(forKey: "notifications_disabled")
         var notificationsEnabledInSystem = false
@@ -77,7 +78,7 @@ class ConnectivityViewController: WebViewViewController {
                 .appending(String.localized("bg_app_refresh_disabled"))
         }
 
-        if !hasNotifyToken {
+        if !hasNotifyToken || connectiviy == DC_CONNECTIVITY_NOT_CONNECTED {
             return "<span class=\"red dot\"></span>"
                 .appending(title)
                 .appending(String.localized("connectivity_not_connected"))