mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 06:45:20 +00:00
Fix iOS background Bluetooth connectivity issues (#378)
- Implement Core Bluetooth state restoration with restoration identifiers - Add background task management to protect critical BLE operations - Fix aggressive battery optimization that killed background connectivity - Disable scan duty cycling in background (was causing 89-97% downtime) - Add missing didEnterBackground/willEnterForeground notifications - Fix advertising cutoff in low battery conditions (now only <10%) - Add background-processing entitlement to Info.plist - Optimize scan parameters for background vs foreground modes These changes address the issue where devices lose mesh connectivity when the app is backgrounded, ensuring continuous Bluetooth operation within iOS background execution limits. Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
@@ -184,13 +184,15 @@ class BatteryOptimizer {
|
||||
// When charging, use performance mode unless battery is critical
|
||||
currentPowerMode = batteryLevel < 0.1 ? .balanced : .performance
|
||||
} else if isInBackground {
|
||||
// In background, always use power saving
|
||||
if batteryLevel < 0.2 {
|
||||
// In background, be less aggressive with power management
|
||||
// Don't force ultra-low power mode until battery is below 10%
|
||||
// Use balanced mode in background above 30% battery
|
||||
if batteryLevel < 0.1 {
|
||||
currentPowerMode = .ultraLowPower
|
||||
} else if batteryLevel < 0.5 {
|
||||
} else if batteryLevel < 0.3 {
|
||||
currentPowerMode = .powerSaver
|
||||
} else {
|
||||
currentPowerMode = .balanced
|
||||
currentPowerMode = .balanced // Use balanced mode above 30% in background
|
||||
}
|
||||
} else {
|
||||
// Foreground, not charging
|
||||
|
||||
Reference in New Issue
Block a user