Fixed iOS notifications when it's an emoji reaction

Fixed new nullable variable in wrapper
This commit is contained in:
Benoit Martins 2023-09-19 16:45:17 +02:00 committed by QuentinArguillere
parent f28a38d838
commit 2e77d7bc84
4 changed files with 19 additions and 7 deletions

View file

@ -83,10 +83,11 @@ import linphonesw
if let addr = searchResult.address, let foundContact = getContactFromAddr(addr: addr) { if let addr = searchResult.address, let foundContact = getContactFromAddr(addr: addr) {
return foundContact return foundContact
} }
if searchResult.phoneNumber != nil { if searchResult.phoneNumber != nil {
if let foundContact = getContactFromPhoneNb(phoneNb: searchResult.phoneNumber!) { if let foundContact = getContactFromPhoneNb(phoneNb: searchResult.phoneNumber!) {
return foundContact return foundContact
} }
} }
// Friend comes from provisioning // Friend comes from provisioning

View file

@ -625,7 +625,8 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
} }
viewer.imageViewer = image viewer.imageViewer = image
viewer.imageNameViewer = chatMessage.contents.first!.name!.isEmpty ? "" : chatMessage.contents.first!.name! viewer.imageNameViewer = (chatMessage.contents.first!.name!.isEmpty ? "" : chatMessage.contents.first!.name)!
viewer.imagePathViewer = chatMessage.contents.first!.exportPlainFile() viewer.imagePathViewer = chatMessage.contents.first!.exportPlainFile()
viewer.contentType = chatMessage.contents.first!.type viewer.contentType = chatMessage.contents.first!.type
PhoneMainView.instance().changeCurrentView(viewer.compositeViewDescription()) PhoneMainView.instance().changeCurrentView(viewer.compositeViewDescription())
@ -701,7 +702,7 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
} }
viewer.imageViewer = image viewer.imageViewer = image
viewer.imageNameViewer = chatMessage!.contents[index].name!.isEmpty ? "" : chatMessage!.contents[index].name! viewer.imageNameViewer = (chatMessage!.contents[index].name!.isEmpty ? "" : chatMessage!.contents[index].name)!
viewer.imagePathViewer = chatMessage!.contents[index].exportPlainFile() viewer.imagePathViewer = chatMessage!.contents[index].exportPlainFile()
viewer.contentType = chatMessage!.contents[index].type viewer.contentType = chatMessage!.contents[index].type
PhoneMainView.instance().changeCurrentView(viewer.compositeViewDescription()) PhoneMainView.instance().changeCurrentView(viewer.compositeViewDescription())

View file

@ -133,8 +133,13 @@ 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")
contentHandler(bestAttemptContent) if message.reactionContent != " " {
contentHandler(bestAttemptContent)
}else {
contentHandler(UNNotificationContent())
}
return return
} else { } else {
NotificationService.log.message(message: "Message not found for callid ["+callId+"]") NotificationService.log.message(message: "Message not found for callid ["+callId+"]")
@ -183,6 +188,7 @@ class NotificationService: UNNotificationServiceExtension {
let callId = message.callId let callId = message.callId
let localUri = message.localAddr?.asStringUriOnly() let localUri = message.localAddr?.asStringUriOnly()
let peerUri = message.peerAddr?.asStringUriOnly() let peerUri = message.peerAddr?.asStringUriOnly()
let reactionContent = message.reactionContent
let from: String let from: String
if let fromDisplayName = message.fromAddr?.asStringUriOnly().getDisplayNameFromSipAddress(lc: lc!, logger: NotificationService.log, groupId: APP_GROUP_ID) { if let fromDisplayName = message.fromAddr?.asStringUriOnly().getDisplayNameFromSipAddress(lc: lc!, logger: NotificationService.log, groupId: APP_GROUP_ID) {
from = fromDisplayName from = fromDisplayName
@ -196,7 +202,11 @@ class NotificationService: UNNotificationServiceExtension {
if let showMsg = lc!.config?.getBool(section: "app", key: "show_msg_in_notif", defaultValue: true), showMsg == true { if let showMsg = lc!.config?.getBool(section: "app", key: "show_msg_in_notif", defaultValue: true), showMsg == true {
if let subject = message.subject as String?, subject != "" { if let subject = message.subject as String?, subject != "" {
msgData.subtitle = subject msgData.subtitle = subject
msgData.body = from + " : " + content if reactionContent == nil {
msgData.body = from + " : " + content
} else {
msgData.body = from + NSLocalizedString(" has reacted by ", comment: "") + reactionContent! + NSLocalizedString(" to: ", comment: "") + content
}
} else { } else {
msgData.subtitle = from msgData.subtitle = from
msgData.body = content msgData.body = content