Not Seeing iOS 15 Notification Avatars

I work on a Messaging app. I am trying to update our app so that it will donate communication intents whenever a message is received. The problem is, even though I am successfully creating an INSendMessageIntent, with a sender (INPerson) with an associated INImage, iOS 15 never actually shows the sender's avatar/image.

Is there something more I need to do? This is basically what my code does:

INImage *senderImage = [INImage imageWithImageData:imageData];

INPerson *const contact = [[INPerson alloc]
                  initWithPersonHandle:handle
                  nameComponents:components
                  displayName:context.notification.content.title
                  image:senderImage
                  contactIdentifier:nil
                  customIdentifier:senderId.stringValue];

INSendMessageIntent *intent = [[INSendMessageIntent alloc]
                    initWithRecipients:@[recipient]
                    outgoingMessageType:INOutgoingMessageTypeUnknown
                    content:messageText
                    speakableGroupName:nil
                    conversationIdentifier:threadId
                    serviceName:@"Instagram Direct"
                    sender:contact
                    attachments:nil];

nseContentHandler([notifContent contentByUpdatingWithProvider:intent error:&error]);

I am doing all of this in the Notification Service Extension. I can see that the image is valid/nonnull and the contentByUpdatingWithProvider:error: method does not set an error, so I am quite confused

Accepted Reply

Really dumb answer: I needed to add the "Communication Notifications" capability to my project :)

Replies

Really dumb answer: I needed to add the "Communication Notifications" capability to my project :)

HI @nightsd01! Did you do something different than your code? Mine is not changing the icon of the Communication Notification at all, I've tried many variations of where to set the image, still just shows the app Icon on the left side of the notification.

Also, didn't you have to donate (Using INInteraction *interaction) before attach the intent to the notification content?

Thanks!

Angelo Ribeiro.

@aribeironovaes did you manage to make this work. I am also struggling with the notifications to display custom image.

  • did you manage to make this work. I have the same problem.

Add a Comment

you can try

    INPerson *person2 = [[INPerson alloc] initWithPersonHandle:personHandle2
                          nameComponents:nameComponents2
                            displayName:@"displayName2"
                               image:image
                         contactIdentifier:@"contactIdentifier2"
                         customIdentifier:@"customIdentifier2"
                               isMe:YES
                          suggestionType:INPersonSuggestionTypeNone];
     
     
    INPerson *person = [[INPerson alloc]initWithPersonHandle:personHandle
                            nameComponents:nameComponents
                              displayName:@"displayName1"
                                 image:image
                           contactIdentifier:@"contactIdentifier1"
                           customIdentifier:@"customIdentifier1"
                                 isMe:NO
                            suggestionType:INPersonSuggestionTypeNone];
     
    INSpeakableString *speakableGroupName = [[INSpeakableString alloc] initWithSpokenPhrase:@"speakableGroupName"];
     
    INSendMessageIntent *sendMessageIntent = [[INSendMessageIntent alloc]
              initWithRecipients:@[person2]
              outgoingMessageType:INOutgoingMessageTypeOutgoingMessageText
              content:nil
              speakableGroupName:speakableGroupName
              conversationIdentifier:@"threadId"
              serviceName:@"serviceName"
              sender:person
              attachments:nil];