firebase / firebase/firebase-admin-java

FCM - Notification Image not displaying

Offen
#818 3 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
api: messaging
Vorherrschende Sprache
Java
Sterne
620
Forks
305
Ø Merge
3 Std. 23 Min.
Gemergte PRs (30 T.)
1

Beschreibung

### 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 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der referenzierten src/main/java/com/google/firebase/messaging/Notification.java und vergleiche das Feld image mit der verlinkten Node.js-Referenz imageUrl. Verfolge, wie Notification in der FCM-Anfrage dargestellt wird, und validiere anschließend das bereitgestellte Multicast-Beispiel auf iOS und Android; abgeschlossen ist die Aufgabe, wenn das Benachrichtigungsbild angezeigt wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
firebase, java
Bereich
api, backend
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.