diff --git a/Linphone/LinphoneApp.swift b/Linphone/LinphoneApp.swift index 487346789..0484bbc24 100644 --- a/Linphone/LinphoneApp.swift +++ b/Linphone/LinphoneApp.swift @@ -87,12 +87,24 @@ class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDele 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]) - } + let strPeerAddr = userInfo["peer_addr"] as? String + if strPeerAddr == nil { + completionHandler([.banner, .sound]) + } else { + // Only display notification if we're not in the chatroom they come from + if displayedChatroomPeerAddr != strPeerAddr { + CoreContext.shared.doOnCoreQueue { core in + let nilParams: ConferenceParams? = nil + if let peerAddr = try? Factory.Instance.createAddress(addr: strPeerAddr!) + , let chatroom = core.searchChatRoom(params: nilParams, localAddr: nil, remoteAddr: peerAddr, participants: nil), chatroom.muted { + Log.info("message comes from a muted chatroom, ignore it") + return + } + completionHandler([.banner, .sound]) + } + } } + } func applicationWillTerminate(_ application: UIApplication) { diff --git a/msgNotificationService/NotificationService.swift b/msgNotificationService/NotificationService.swift index d8e77cbc8..ae04eba6c 100644 --- a/msgNotificationService/NotificationService.swift +++ b/msgNotificationService/NotificationService.swift @@ -147,6 +147,14 @@ class NotificationService: UNNotificationServiceExtension { let message = lc!.getNewMessageFromCallid(callId: callId) if let message = message { + let nilParams: ConferenceParams? = nil + if let peerAddr = message.peerAddr + , let chatroom = lc!.searchChatRoom(params: nilParams, localAddr: nil, remoteAddr: peerAddr, participants: nil), chatroom.muted { + Log.info("message comes from a muted chatroom, ignore it") + stopCore() + contentHandler(UNNotificationContent()) + return + } let msgData = parseMessage(message: message) // Extension only upates app's badge when main shared core is Off = extension's core is On.