Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

FCM - Notification Image not displaying

未关闭
#818 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
firebase, java
领域
api, backend

调研方向

从所引用的 src/main/java/com/google/firebase/messaging/Notification.java 开始,并将其 image 字段与链接的 Node.js imageUrl 参考进行比较。追踪 Notification 在 FCM 请求中的表示方式,然后在 iOS 和 Android 上验证所提供的 multicast 示例;当通知图像显示出来时即表示完成。

由索引模型根据 Issue 内容生成。

描述

api: messaging
Describe your environment
  • Operating System version: macOS 13.0 (22A380)
  • Firebase SDK version: 9.1.1
  • Library version: 9.1.1
  • Firebase Product: Cloud Messaging (auth, database, storage, etc)
Steps to reproduce:

Images are not displayed on devices (both iOS and Android) when sending notifications with FCM.
I set the image URL using the Notification Builder.

List<String> fcmTokens = List.of(...);

Notification notification = Notification.builder().setTitle("Hello").setBody("world").setImage("https://e-cdns-images.dzcdn.net/images/cover/f2d3db07f3f045a048cdacf53b5cf9dd/250x250-000000-80-0-0.jpg").build();

MulticastMessage message = MulticastMessage.builder()
                .setNotification(notification)
                .addAllTokens(fcmTokens).build();

BatchResponse response = FirebaseMessaging.getInstance().sendMulticast(message);

Note that I receive the notification on the devices, only the image is not displayed. I am able to see the image in the notification when sending it using the Firebase Console.

When investigating the issue, I discovered that other SDKs use imageUrl instead of image attribute.
For example, for NodeJS: https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.notification.md#notificationimageurl

The Java SDK still uses the image key instead of imageUrl: https://github.com/firebase/firebase-admin-java/blob/master/src/main/java/com/google/firebase/messaging/Notification.java#L33

主要语言
Java
星标
620
派生
305
平均合并
4 天 9 小时
30 天内合并 PR
4

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/firebase-admin-java 的其他 Issue

查看 firebase/firebase-admin-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。