Skip to content

Instantly share code, notes, and snippets.

@simonbs
Created July 27, 2026 17:56
Show Gist options
  • Select an option

  • Save simonbs/e470b44b2b0b86accbf5a8cd8eeeb379 to your computer and use it in GitHub Desktop.

Select an option

Save simonbs/e470b44b2b0b86accbf5a8cd8eeeb379 to your computer and use it in GitHub Desktop.
Setting a custom icon on an otification
struct NotificationIconPresenter {
func content(from content: UNMutableNotificationContent, iconFileURL: URL) -> UNNotificationContent? {
guard let icon = INImage(url: iconFileURL) else {
return nil
}
let senderName = Self.senderName(for: content)
let sender = INPerson(
personHandle: INPersonHandle(value: senderName, type: .unknown),
nameComponents: nil,
displayName: senderName,
image: icon,
contactIdentifier: nil,
customIdentifier: senderName
)
let intent = INSendMessageIntent(
recipients: nil,
outgoingMessageType: .outgoingMessageText,
content: nil,
speakableGroupName: nil,
conversationIdentifier: Self.conversationIdentifier(for: content),
serviceName: nil,
sender: sender,
attachments: nil
)
intent.setImage(icon, forParameterNamed: \INSendMessageIntent.sender)
return try? content.updating(from: intent)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment