mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-17 20:08:31 +00:00
Add a wait time of up to 3 second inside the app extension, then iterate to try and receive the NOTIFY required for imdn sending
This commit is contained in:
parent
b8efad4980
commit
fa9be23c2d
1 changed files with 284 additions and 278 deletions
|
|
@ -89,7 +89,7 @@ class NotificationService: UNNotificationServiceExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
||||||
|
let timeStart = Date.now
|
||||||
self.contentHandler = contentHandler
|
self.contentHandler = contentHandler
|
||||||
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
|
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
|
||||||
|
|
||||||
|
|
@ -172,6 +172,7 @@ class NotificationService: UNNotificationServiceExtension {
|
||||||
let message = lc!.getNewMessageFromCallid(callId: callId)
|
let message = lc!.getNewMessageFromCallid(callId: callId)
|
||||||
|
|
||||||
if let message = message {
|
if let message = message {
|
||||||
|
|
||||||
let nilParams: ConferenceParams? = nil
|
let nilParams: ConferenceParams? = nil
|
||||||
if let peerAddr = message.peerAddr
|
if let peerAddr = message.peerAddr
|
||||||
, let chatroom = lc!.searchChatRoom(params: nilParams, localAddr: nil, remoteAddr: peerAddr, participants: nil), chatroom.muted {
|
, let chatroom = lc!.searchChatRoom(params: nilParams, localAddr: nil, remoteAddr: peerAddr, participants: nil), chatroom.muted {
|
||||||
|
|
@ -188,7 +189,6 @@ class NotificationService: UNNotificationServiceExtension {
|
||||||
bestAttemptContent.badge = badge
|
bestAttemptContent.badge = badge
|
||||||
}
|
}
|
||||||
|
|
||||||
stopCore()
|
|
||||||
bestAttemptContent.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "msg.caf"))
|
bestAttemptContent.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "msg.caf"))
|
||||||
bestAttemptContent.title = String(localized: "notification_chat_message_received_title")
|
bestAttemptContent.title = String(localized: "notification_chat_message_received_title")
|
||||||
if let subtitle = msgData?.subtitle {
|
if let subtitle = msgData?.subtitle {
|
||||||
|
|
@ -204,12 +204,18 @@ class NotificationService: UNNotificationServiceExtension {
|
||||||
bestAttemptContent.userInfo.updateValue(msgData?.from as Any, forKey: "from")
|
bestAttemptContent.userInfo.updateValue(msgData?.from as Any, forKey: "from")
|
||||||
bestAttemptContent.userInfo.updateValue(msgData?.peerAddr as Any, forKey: "peer_addr")
|
bestAttemptContent.userInfo.updateValue(msgData?.peerAddr as Any, forKey: "peer_addr")
|
||||||
bestAttemptContent.userInfo.updateValue(msgData?.localAddr as Any, forKey: "local_addr")
|
bestAttemptContent.userInfo.updateValue(msgData?.localAddr as Any, forKey: "local_addr")
|
||||||
|
|
||||||
|
// start remaining time count 25 instead of 30 to make sure we keep at least 5 seconds to finish the message processing
|
||||||
|
let remainingTime = max(0, 25 - Date.now.timeIntervalSince(timeStart))
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + min(3, remainingTime)) {
|
||||||
|
self.lc?.iterate()
|
||||||
|
self.stopCore()
|
||||||
if message.reactionContent != " " {
|
if message.reactionContent != " " {
|
||||||
contentHandler(bestAttemptContent)
|
contentHandler(bestAttemptContent)
|
||||||
} else {
|
} else {
|
||||||
contentHandler(UNNotificationContent())
|
contentHandler(UNNotificationContent())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
Log.info("Message not found for callid ["+callId+"]")
|
Log.info("Message not found for callid ["+callId+"]")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue