2.5 KiB
2.5 KiB
Communication Notifications (avatar + app-icon badge)
The Notification Service Extension (NotificationService.swift) turns incoming
pushes into communication notifications on iOS 15+: a large circular avatar
(the sending network's photo) with the app icon badged in the corner.
How it works
- The server (
frm.so,notifications.js) setsmutableContent: 1and adds to the push payload:imageUrl— a PNG of the network's logo (the server rasterizes SVG logos to PNG viasharp, since iOS can't render SVG avatars).senderName— the network name (used as the conversation title; falls back to the notification's own title).isGroup—true, so iOS uses the group-avatar style.
- The extension downloads
imageUrl, builds anINSendMessageIntentwith the image as the sender/group avatar, donates it, and returnscontent.updating(from: intent). - On iOS 14 the extension falls back to attaching the image as a plain thumbnail.
Required setup (both pieces are mandatory)
Two things must be in place or the avatar silently won't render:
1. NSUserActivityTypes declares the intent (already in this repo)
INSendMessageIntent is declared under NSUserActivityTypes in both
App/Info.plist and NotificationService/Info.plist. Without this the donation
fails with "Donating intent 'INSendMessageIntent' is not supported by this
extension" and the communication styling never applies.
2. Communication Notifications capability (one-time, in Xcode — cannot be scripted)
The capability must be registered on the provisioning profile, not just present in the entitlements file:
- Open
ios/App/App.xcworkspacein Xcode. - Select the App target → Signing & Capabilities → + Capability →
add Communication Notifications.
- This adds
com.apple.developer.usernotifications.communicationtoApp.entitlements(already in this repo) and, crucially, enables the capability on the App ID / provisioning profile. Requires a paid Apple Developer account.
- This adds
- If the avatar still doesn't appear, add the same capability to the NotificationService target as well.
- Rebuild and reinstall on a device (communication notifications don't reliably render on the Simulator).
Notes
- Requires iOS 15.0+ for the communication style; older versions get the plain attachment fallback automatically.
- The app's deployment target is currently 14.0, so no bump is required.