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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user