Ensure core is On before stopping it on background entry

This commit is contained in:
Benoit Martins 2025-09-04 16:40:34 +02:00
parent 14635250f8
commit a7e2ebb600

View file

@ -424,26 +424,24 @@ class CoreContext: ObservableObject {
func onEnterForeground() {
coreQueue.async {
// We can't rely on defaultAccount?.params?.isPublishEnabled
// as it will be modified by the SDK when changing the presence status
Log.info("[onEnterForegroundOrBackground] Entering foreground")
try? self.mCore.start()
}
}
func onEnterBackground() {
coreQueue.async {
// We can't rely on defaultAccount?.params?.isPublishEnabled
// as it will be modified by the SDK when changing the presence status
Log.info("App is in background, un-PUBLISHING presence info")
Log.info("[onEnterForegroundOrBackground] Entering background, un-PUBLISHING presence info")
// We don't use ConsolidatedPresence.Busy but Offline to do an unsubscribe,
// Flexisip will handle the Busy status depending on other devices
self.updatePresence(core: self.mCore, presence: ConsolidatedPresence.Offline)
self.updatePresence(core: self.mCore, presence: .Offline)
self.mCore.iterate()
if self.mCore.currentCall == nil {
if self.mCore.currentCall == nil && self.mCore.globalState == .On {
Log.info("[onEnterForegroundOrBackground] Stopping core because no active calls")
self.mCore.stop()
} else {
Log.info("[onEnterForegroundOrBackground] Skipped stop: core not fully On or active call in progress")
}
}
}