Hey,
I tried adding a user avatar to my notifications using a Notification Service Extension.
let (imageData, _) = try await URLSession.shared.data(from: URL(string: profile.profilePictureLink)!)
let handle = INPersonHandle(value: profile.profileId, type: .unknown)
let avatar = INImage(imageData: imageData)
var nameComponents = PersonNameComponents()
nameComponents.givenName = profile.firstname
nameComponents.middleName = profile.middlename
nameComponents.familyName = profile.lastname
nameComponents.nickname = profile.username
let sender = INPerson(personHandle: handle,
nameComponents: nameComponents,
displayName: profile.displayName(),
image: avatar,
contactIdentifier: nil,
customIdentifier: profile.profileId,
isMe: false,
suggestionType: .none )
let intent = INSendMessageIntent(recipients: nil,
outgoingMessageType: .outgoingMessageText,
content: messageText,
speakableGroupName: INSpeakableString(spokenPhrase: profile.displayName()),
conversationIdentifier: receiverId + "_" + ownerId,
serviceName: nil,
sender: sender,
attachments: nil)
intent.setImage(avatar, forParameterNamed: \.sender)
let interaction = INInteraction(intent: intent, response: nil)
interaction.direction = .incoming
interaction.donate(completion: nil)
do {
let updatedContent = try bestAttemptContent.updating(from: intent)
contentHandler(updatedContent)
} catch {
print(error)
}
I've added the communication notification entitlement to my app. As well as the NSUserActivityTypes in my main target's Info.plist. I also added IntentsSupported to my Notification Service Extension's Info.plist. I also tried it with NSUserActivityTypes but neither of them works.
Also I see these logs in console:
2022-11-19 21:29:07.490915+0100 NotificationService[5252:369887] [Intents] -[INCache cacheableObjectForIdentifier:] Unable to find cacheable object with identifier F1FE1921-0894-5FEB-FF33-934EAD5C6E4F in cache.
2022-11-19 21:29:07.491058+0100 NotificationService[5252:369887] [Intents] -[INCache cacheableObjectForIdentifier:] Unable to find cacheable object with identifier F1FE1921-0894-5FEB-FF33-934EAD5C6E4F in cache.
2022-11-19 21:29:07.510673+0100 NotificationService[5252:369888] [default] LaunchServices: store (null) or url (null) was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=66, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
2022-11-19 21:29:07.510708+0100 NotificationService[5252:369888] [default] Attempt to map database failed: permission was denied. This attempt will not be retried.
2022-11-19 21:29:07.510737+0100 NotificationService[5252:369888] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=66, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
2022-11-19 21:29:07.510789+0100 NotificationService[5252:369888] [Intents] +[INAppInfo appInfoWithAppProxy:] Unable to create app info with application record: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=66, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
2022-11-19 21:29:07.579663+0100 NotificationService[5252:369887] [RemoteNotifications] [A946BFD5-50A2-4140-835B-A23047340D1F] Ignoring additional replacement content replies for notification request 2FDA-6FE6
2022-11-19 21:29:07.579879+0100 NotificationService[5252:369900] [Intents] -[INCache cacheableObjectForIdentifier:] Unable to find cacheable object with identifier intents-remote-image-proxy:?proxyIdentifier=F1FE1921-0894-5FEB-FF33-934EAD5C6E4F.png&storageServiceIdentifier=com.apple.Intents.INImageServiceConnection in cache.
2022-11-19 21:29:07.580177+0100 NotificationService[5252:369900] [Intents] -[INCache cacheableObjectForIdentifier:] Unable to find cacheable object with identifier intents-remote-image-proxy:?proxyIdentifier=F1FE1921-0894-5FEB-FF33-934EAD5C6E4F.png&storageServiceIdentifier=com.apple.Intents.INImageServiceConnection in cache.
Does anybody know what I'm missing?