chore: update dependencies and enhance connectivity service

- Added `connectivity_plus` dependency to manage network connectivity status.
- Updated `pubspec.yaml` to include the new dependency version.
- Enhanced `ConnectivityService` to utilize `connectivity_plus` for improved connectivity monitoring and handling.
- Refactored connectivity checks and state management for better performance and reliability.
This commit is contained in:
cogwheel0
2025-10-09 00:45:00 +05:30
parent fabb1df63a
commit 052a68e3b6
5 changed files with 210 additions and 53 deletions

View File

@@ -122,11 +122,26 @@ class BackgroundStreamingHandler: NSObject {
}
private func saveStreamStates(_ states: [[String: Any]]) {
UserDefaults.standard.set(states, forKey: "ConduitActiveStreams")
do {
let jsonData = try JSONSerialization.data(withJSONObject: states, options: [])
UserDefaults.standard.set(jsonData, forKey: "ConduitActiveStreams")
} catch {
print("BackgroundStreamingHandler: Failed to serialize stream states: \(error)")
}
}
private func recoverStreamStates() -> [[String: Any]] {
return UserDefaults.standard.array(forKey: "ConduitActiveStreams") as? [[String: Any]] ?? []
guard let jsonData = UserDefaults.standard.data(forKey: "ConduitActiveStreams") else {
return []
}
do {
if let states = try JSONSerialization.jsonObject(with: jsonData, options: []) as? [[String: Any]] {
return states
}
} catch {
print("BackgroundStreamingHandler: Failed to deserialize stream states: \(error)")
}
return []
}
deinit {