@@ -51,10 +51,38 @@ struct IterableAPICallTaskProcessor: IterableTaskProcessor {
5151 private let dateProvider : DateProviderProtocol
5252
5353 private static func isNetworkUnavailable( sendRequestError: SendRequestError ) -> Bool {
54+ // Check for NSURLError codes that indicate network issues
55+ if let nsError = sendRequestError. originalError as? NSError {
56+ if nsError. domain == NSURLErrorDomain {
57+ let networkErrorCodes : Set < Int > = [
58+ NSURLErrorNotConnectedToInternet, // -1009
59+ NSURLErrorNetworkConnectionLost, // -1005
60+ NSURLErrorTimedOut, // -1001
61+ NSURLErrorCannotConnectToHost, // -1004
62+ NSURLErrorDNSLookupFailed, // -1006
63+ NSURLErrorDataNotAllowed, // -1020 (cellular data disabled)
64+ NSURLErrorInternationalRoamingOff // -1018
65+ ]
66+ if networkErrorCodes. contains ( nsError. code) {
67+ ITBInfo ( " Network error detected: code= \( nsError. code) , description= \( nsError. localizedDescription) " )
68+ return true
69+ }
70+ }
71+ }
72+
73+ // Fallback to string check for other network-related errors
5474 if let originalError = sendRequestError. originalError {
55- return originalError. localizedDescription. lowercased ( ) . contains ( " offline " )
56- } else {
57- return false
75+ let description = originalError. localizedDescription. lowercased ( )
76+ let isNetworkError = description. contains ( " offline " ) ||
77+ description. contains ( " network " ) ||
78+ description. contains ( " internet " ) ||
79+ description. contains ( " connection " )
80+ if isNetworkError {
81+ ITBInfo ( " Network error detected via description: \( originalError. localizedDescription) " )
82+ }
83+ return isNetworkError
5884 }
85+
86+ return false
5987 }
6088}
0 commit comments