diff --git a/Linphone.xcodeproj/project.pbxproj b/Linphone.xcodeproj/project.pbxproj index 2d7269dd7..e120285cc 100644 --- a/Linphone.xcodeproj/project.pbxproj +++ b/Linphone.xcodeproj/project.pbxproj @@ -1250,7 +1250,7 @@ CODE_SIGN_ENTITLEMENTS = msgNotificationService/msgNotificationService.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 53; + CURRENT_PROJECT_VERSION = 55; DEVELOPMENT_TEAM = Z2V957B3D6; ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu17; @@ -1293,7 +1293,7 @@ CODE_SIGN_ENTITLEMENTS = msgNotificationService/msgNotificationService.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 53; + CURRENT_PROJECT_VERSION = 55; DEVELOPMENT_TEAM = Z2V957B3D6; ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu17; @@ -1450,7 +1450,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_ENTITLEMENTS = Linphone/Linphone.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 53; + CURRENT_PROJECT_VERSION = 55; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_ASSET_PATHS = "\"Linphone/Preview Content\""; @@ -1507,7 +1507,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_ENTITLEMENTS = Linphone/Linphone.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 53; + CURRENT_PROJECT_VERSION = 55; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Linphone/Preview Content\""; DEVELOPMENT_TEAM = Z2V957B3D6; diff --git a/Linphone/Core/CoreContext.swift b/Linphone/Core/CoreContext.swift index 5f168ff1f..44ddbae7e 100644 --- a/Linphone/Core/CoreContext.swift +++ b/Linphone/Core/CoreContext.swift @@ -363,10 +363,6 @@ final class CoreContext: ObservableObject { mCore.removeDelegate(delegate: delegate) } - func getCorePublisher() -> CoreDelegatePublisher? { - return mCore.publisher - } - } // swiftlint:enable line_length diff --git a/Linphone/LinphoneApp.swift b/Linphone/LinphoneApp.swift index 9ecfffa09..487346789 100644 --- a/Linphone/LinphoneApp.swift +++ b/Linphone/LinphoneApp.swift @@ -22,6 +22,7 @@ import linphonesw import UserNotifications let accountTokenNotification = Notification.Name("AccountCreationTokenReceived") +var displayedChatroomPeerAddr: String? class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate { @@ -81,6 +82,19 @@ class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDele completionHandler() } + // Display notifications on foreground + func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { + let userInfo = notification.request.content.userInfo + Log.info("Received push notification in foreground, payload= \(userInfo)") + + if let callId = userInfo["CallId"] as? String, let peerAddr = userInfo["peer_addr"] as? String, let localAddr = userInfo["local_addr"] as? String { + // Only display notification if we're not in the chatroom they come from + if displayedChatroomPeerAddr != peerAddr { + completionHandler([.banner, .sound]) + } + } + } + func applicationWillTerminate(_ application: UIApplication) { Log.info("IOS applicationWillTerminate") CoreContext.shared.doOnCoreQueue(synchronous: true) { core in diff --git a/Linphone/UI/Main/ContentView.swift b/Linphone/UI/Main/ContentView.swift index 0dd98f609..599143a0d 100644 --- a/Linphone/UI/Main/ContentView.swift +++ b/Linphone/UI/Main/ContentView.swift @@ -1243,9 +1243,9 @@ struct ContentView: View { } class NavigationManager: ObservableObject { - @Published var selectedCallId: String? = nil - @Published var peerAddr: String? = nil - @Published var localAddr: String? = nil + @Published var selectedCallId: String? + @Published var peerAddr: String? + @Published var localAddr: String? func openChatRoom(callId: String, peerAddr: String, localAddr: String) { self.selectedCallId = callId diff --git a/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift b/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift index 685eb2260..8aa44389e 100644 --- a/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift +++ b/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift @@ -69,7 +69,13 @@ struct ConversationFragment: View { .onRotate { newOrientation in orientation = newOrientation } + .onAppear() { + displayedChatroomPeerAddr = conversationViewModel.displayedConversation?.remoteSipUri + Log.info("debugtrace = onAppear: displayedChatroomPeerAddr = \(displayedChatroomPeerAddr)") + } .onDisappear { + displayedChatroomPeerAddr = nil + Log.info("debugtrace = onDisappear: displayedChatroomPeerAddr = nil") conversationViewModel.removeConversationDelegate() } .sheet(isPresented: $conversationViewModel.isShowSelectedMessageToDisplayDetails, onDismiss: { @@ -109,7 +115,13 @@ struct ConversationFragment: View { .onRotate { newOrientation in orientation = newOrientation } + .onAppear() { + displayedChatroomPeerAddr = conversationViewModel.displayedConversation?.remoteSipUri + Log.info("debugtrace = onAppear: displayedChatroomPeerAddr = \(displayedChatroomPeerAddr)") + } .onDisappear { + displayedChatroomPeerAddr = nil + Log.info("debugtrace = onDisappear: displayedChatroomPeerAddr = nil") conversationViewModel.removeConversationDelegate() } .halfSheet(showSheet: $conversationViewModel.isShowSelectedMessageToDisplayDetails) {