Skip to content

Commit

Permalink
fix ios streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiska committed Jun 28, 2024
1 parent e0c69b1 commit 7647490
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ios/Classes/FlutterEcoModePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ public class PowerModeStreamHandler: NSObject, FlutterStreamHandler {

@objc
func lowPowerModeChanged() {
self.eventSink?(ProcessInfo.processInfo.isLowPowerModeEnabled)
DispatchQueue.main.async {
self.eventSink?(ProcessInfo.processInfo.isLowPowerModeEnabled)
}
}

}
Expand All @@ -190,7 +192,9 @@ public class BatteryStateStreamHandler: NSObject, FlutterStreamHandler {

@objc func batteryStateChanged(_ notification: Notification) {
let batteryState = convertBatteryState(state: UIDevice.current.batteryState)
self.eventSink?(batteryState)
DispatchQueue.main.async {
self.eventSink?(batteryState)
}
}

}
Expand All @@ -215,6 +219,9 @@ public class BatteryLevelStreamHandler: NSObject, FlutterStreamHandler {
@objc func batteryLevelChanged(_ notification: Notification) {
let batteryLevel = Double(UIDevice.current.batteryLevel)
self.eventSink?(batteryLevel)
DispatchQueue.main.async {
self.eventSink?(batteryLevel)
}
}

}
Expand Down

0 comments on commit 7647490

Please sign in to comment.