forked from mirrors/linphone-iphone
Send own presence
This commit is contained in:
parent
7b476904cb
commit
8b14538fcd
3 changed files with 29 additions and 1 deletions
|
|
@ -123,6 +123,9 @@ final class CoreContext: ObservableObject {
|
|||
if cbVal.state == .Ok {
|
||||
self.loggingInProgress = false
|
||||
self.loggedIn = true
|
||||
if self.mCore.consolidatedPresence != ConsolidatedPresence.Online {
|
||||
self.onForeground()
|
||||
}
|
||||
} else if cbVal.state == .Progress {
|
||||
self.loggingInProgress = true
|
||||
} else {
|
||||
|
|
@ -154,6 +157,30 @@ final class CoreContext: ObservableObject {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
func onForeground() {
|
||||
coreQueue.async {
|
||||
// We can't rely on defaultAccount?.params?.isPublishEnabled
|
||||
// as it will be modified by the SDK when changing the presence status
|
||||
if self.mCore.config!.getBool(section: "app", key: "publish_presence", defaultValue: true) {
|
||||
NSLog("App is in foreground, PUBLISHING presence as Online")
|
||||
self.mCore.consolidatedPresence = ConsolidatedPresence.Online
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func onBackground() {
|
||||
coreQueue.async {
|
||||
// We can't rely on defaultAccount?.params?.isPublishEnabled
|
||||
// as it will be modified by the SDK when changing the presence status
|
||||
if self.mCore.config!.getBool(section: "app", key: "publish_presence", defaultValue: true) {
|
||||
NSLog("App is in 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.mCore.consolidatedPresence = ConsolidatedPresence.Offline
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// swiftlint:enable large_tuple
|
||||
|
|
|
|||
|
|
@ -504,7 +504,6 @@ struct EditContactFragment: View {
|
|||
let result = ContactsManager.shared.lastSearch.firstIndex(where: {
|
||||
$0.friend!.name == newContact.firstName + " " + newContact.lastName
|
||||
})
|
||||
print("getFriendIndexWithFriendgetFriendIndexWithFriend \(newContact.firstName) \(newContact.lastName) \(result)")
|
||||
contactViewModel.indexDisplayedFriend = result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -625,11 +625,13 @@ struct ContentView: View {
|
|||
}
|
||||
.onChange(of: scenePhase) { newPhase in
|
||||
if newPhase == .active {
|
||||
coreContext.onForeground()
|
||||
contactsManager.fetchContacts()
|
||||
print("Active")
|
||||
} else if newPhase == .inactive {
|
||||
print("Inactive")
|
||||
} else if newPhase == .background {
|
||||
coreContext.onBackground()
|
||||
print("Background")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue