소스 검색

retry to aquire a notification token if the app has none yet and the device gets internet connectivity

cyberta 3 년 전
부모
커밋
8b19962e59
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      deltachat-ios/AppDelegate.swift

+ 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()
+                }
             }
         }