Notification does not show as communication notification

Hi all,

I am trying to implement the communication notification for me app. But the avatar does not show and there is virtually no difference from a normal notification.

I also added the Communication Notification capability, and in my Notification Service Extension's Info.plist, added this: NSExtension → NSExtensionAttributes (dictionary) → IntentsSupported (array) → INSendMessageIntent (string)

What am I doing wrong?

Here is my code:

class NotificationService: UNNotificationServiceExtension {

    var contentHandler: ((UNNotificationContent) -> Void)?

    var bestAttemptContent: UNMutableNotificationContent?

    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
        
        var personNameComponents = PersonNameComponents()

        personNameComponents.nickname = "Sender Name"

        let avatar = INImage(named: "Cover")

        let senderPerson = INPerson(personHandle: INPersonHandle(value: "1233211234", type: .unknown), nameComponents: personNameComponents, displayName: "Sender Name", image: avatar, contactIdentifier: nil, customIdentifier: nil, isMe: false, suggestionType: .none)

        let mePerson = INPerson( personHandle: INPersonHandle(value: "1233211232", type: .unknown), nameComponents: nil, displayName: nil, image: nil, contactIdentifier: nil, customIdentifier: nil, isMe: true, suggestionType: .none)

        let incomingMessagingIntent = INSendMessageIntent(recipients: [mePerson], outgoingMessageType: .outgoingMessageText, content: "Test DUde", speakableGroupName: nil, conversationIdentifier: "uid", serviceName: "caset", sender: senderPerson, attachments: [])

        incomingMessagingIntent.setImage(avatar, forParameterNamed: \.sender)

        let interaction = INInteraction(intent: incomingMessagingIntent, response: nil)

        interaction.direction = .incoming

        do {

            let newContent = try request.content.updating(from: incomingMessagingIntent)

            contentHandler(newContent)

        } catch {

            print(error)

        }

    }

    override func serviceExtensionTimeWillExpire() {

        // Called just before the extension will be terminated by the system.

        // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.

        if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {

            contentHandler(bestAttemptContent)

        }

    }
}
Answered by rinsuki in 690675022

you need to add INSendMessageIntent to NSUserActivityTypes in host app's Info.plist , did you add it?

Accepted Answer

you need to add INSendMessageIntent to NSUserActivityTypes in host app's Info.plist , did you add it?

I. have the same question And
Xcode print logs

[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=264, _LSFunction=-[_LSDReadClient getServerStoreWithCompletionHandler:]}

Notification does not show as communication notification
 
 
Q