Skip to content

[🐛] Bug Report: Attachment Type Not Exposed in Push Notification Template #3496

@Ubaid-0x

Description

@Ubaid-0x

Bug Report: Attachment Type Not Exposed in Push Notification Template

Push Provider: Firebase (FCM) + APNs
Platform: iOS & Android


Problem

When a user sends a message containing only an attachment (image, audio/voice message, video, file, sticker, GIF) with no accompanying text, the push notification body is empty or renders as a blank string.

This happens because:

  1. message.text is empty for attachment-only messages
  2. The v2 template context does not expose message.attachments or any attachment metadata as a renderable template variable
  3. There is no documented way to conditionally render attachment type (e.g. 📷 Photo, 🎵 Voice message) in the push template

Current Template (fails for attachments)

{
  "notification": {
    "title": "{{ sender.name }}",
    "body": "{{ message.text }}"
  }
}

When message.text is empty (attachment-only message), body renders as ""blank notification.


What Was Attempted

Attempt 1 — Access attachment type directly:

"body": "{{ message.attachments.0.type }}"

message.attachments is not available in the template context. Renders empty.

Attempt 2 — Handlebars conditional (Jinja/Liquid syntax, wrong engine):

"body": "{% if message.attachments %}📷 Photo{% endif %}"

Stream uses Handlebars, not Jinja. This renders the raw condition string as-is.

Attempt 3 — Handlebars {{#if}} with (eq) helper:

"body": "{{#if (eq message.attachments.0.type 'image')}}📷 Photo{{/if}}"

Template validation fails(eq) and else if are not supported helpers in Stream's Handlebars subset.

Attempt 4 — Nested {{#if}} without helpers:

"body": "{{#if message.attachments}}{{#if message.attachments.0.title}}{{ message.attachments.0.title }}{{else}}📎 Attachment{{/if}}{{else}}{{ message.text }}{{/if}}"

Template validation failsmessage.attachments is not in the template rendering context at all.


Expected Behavior

One or more of the following should be supported:

Option A — Expose message.attachments in the template context so developers can use {{#if message.attachments}}

Option B — Expose a pre-resolved helper variable like message.attachment_summary that returns a human-readable string (e.g. "📷 Photo", "🎵 Voice message") when message.text is empty

Option C — Document the exact Handlebars subset and available variables for attachment handling so developers can implement a workaround


Impact

Any message sent with only an attachment produces a silent/blank push notification. This affects common use cases:

  • 📷 Photo messages
  • 🎵 Voice/audio messages
  • 🎥 Video messages
  • 📎 File attachments
  • 🎬 Stickers / GIFs

The only current workaround is handling this entirely on the client side after the notification is received, but by that point the notification body has already been displayed blank to the user.


Environment

  • Firebase FCM template via Stream Dashboard
  • iOS (APNs) + Android (FCM)

References


Happy to provide additional logs, payload samples, or test cases if helpful.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions