@@ -58,7 +58,13 @@ func handleNewConversationFirstMessage(xmtpClient: XMTP.Client, apiURI: String?,
58
58
print ( " [NotificationExtension] Not showing a notification " )
59
59
break
60
60
} else if let content = decodedMessageResult. content {
61
- bestAttemptContent. title = shortAddress ( address: try conversation. peerAddress)
61
+ let senderAddress = try conversation. peerAddress
62
+ let conversationTitle : String ? = nil
63
+ if let senderProfile = await getProfile ( account: xmtpClient. address, address: senderAddress) {
64
+ bestAttemptContent. title = getPreferredName ( address: senderAddress, socials: senderProfile. socials)
65
+ } else {
66
+ bestAttemptContent. title = shortAddress ( address: senderAddress)
67
+ }
62
68
bestAttemptContent. body = content
63
69
shouldShowNotification = true
64
70
messageId = decodedMessageResult. id // @todo probably remove this?
@@ -198,15 +204,15 @@ func handleGroupMessage(xmtpClient: XMTP.Client, envelope: XMTP.Envelope, apiURI
198
204
func handleOngoingConversationMessage( xmtpClient: XMTP . Client , envelope: XMTP . Envelope , bestAttemptContent: inout UNMutableNotificationContent , body: [ String : Any ] ) async -> ( shouldShowNotification: Bool , messageId: String ? , messageIntent: INSendMessageIntent ? ) {
199
205
var shouldShowNotification = false
200
206
let contentTopic = envelope. contentTopic
201
- var conversationTitle = getSavedConversationTitle ( contentTopic : contentTopic )
207
+ var conversationTitle : String ? = nil
202
208
var messageId : String ? = nil
203
209
var messageIntent : INSendMessageIntent ? = nil
204
210
205
211
let decodedMessage = try ? await decodeMessage ( xmtpClient: xmtpClient, envelope: envelope)
206
212
// If couldn't decode the message, not showing
207
213
if let message = decodedMessage {
208
214
let decodedMessageResult = handleMessageByContentType ( decodedMessage: message, xmtpClient: xmtpClient) ;
209
-
215
+
210
216
if decodedMessageResult. senderAddress == xmtpClient. address || decodedMessageResult. forceIgnore {
211
217
// Message is from me or a reaction removal, let's drop it
212
218
print ( " [NotificationExtension] Not showing a notification " )
@@ -218,11 +224,14 @@ func handleOngoingConversationMessage(xmtpClient: XMTP.Client, envelope: XMTP.En
218
224
conversationTitle = getPreferredName ( address: senderAddress, socials: senderProfile. socials)
219
225
senderAvatar = getPreferredAvatar ( socials: senderProfile. socials)
220
226
}
221
-
222
- if conversationTitle. isEmpty , let senderAddress = decodedMessageResult. senderAddress {
227
+
228
+ if ( conversationTitle == nil ) , let senderAddress = decodedMessageResult. senderAddress {
223
229
conversationTitle = shortAddress ( address: senderAddress)
224
230
}
225
- bestAttemptContent. title = conversationTitle
231
+ if let convoTitle = conversationTitle {
232
+ bestAttemptContent. title = convoTitle
233
+ }
234
+
226
235
shouldShowNotification = true
227
236
messageId = decodedMessageResult. id
228
237
messageIntent = getIncoming1v1MessageIntent ( topic: envelope. contentTopic, senderId: decodedMessage? . senderAddress ?? " " , senderName: bestAttemptContent. title, senderAvatar: senderAvatar, content: bestAttemptContent. body)
0 commit comments