laravel-notification-channels / fcm

Firebase Cloud Messaging (FCM) notifications channel for Laravel
https://laravel-notification-channels.com/
MIT License
472 stars 121 forks source link

Notifications Request Body is Sent with Null Values #197

Closed kyagie closed 3 months ago

kyagie commented 3 months ago

Here is an example of the notification body received by devices from my remote server. However the request body only has null values. All values are shown the remoteMessage body however. { "notification": { "request": { "content": { "autoDismiss": true, "sound": "default", "data": null, "body": null, "sticky": false, "badge": null, "title": null, "subtitle": null }, "trigger": { "remoteMessage": { "originalPriority": 2, "notification": { "usesDefaultVibrateSettings": false, "visibility": null, "notificationPriority": null, "titleLocalizationArgs": null, "clickAction": null, "color": null, "eventTime": null, "link": null, "usesDefaultSound": false, "channelId": null, "lightSettings": null, "title": "Image Request", "imageUrl": null, "vibrateTimings": null, "tag": null, "localOnly": false, "bodyLocalizationArgs": null, "titleLocalizationKey": null, "ticker": null, "usesDefaultLightSettings": false, "sticky": false, "body": "Please provide an image for billboard: Acacia Road (Acacia area)", "sound": null, "icon": null, "notificationCount": null, "bodyLocalizationKey": null }, }

Here is function to dispatch notifications

` /**

How can I change my code to have the notification data for body and title be present in the request body as well?

dwightwatson commented 3 months ago

There's not enough information here to go off. Can you please try and debug further.

Check what message the channel is passing off because it's sent to the Firebase package. Or use the Firebase package directly and see if the issue persists.

dwightwatson commented 3 months ago

That looks like you're using an older version of the library?

kyagie commented 3 months ago

Using v4.3 image

dwightwatson commented 3 months ago

Sorry - someone else had commented on the issue just before with a screenshot of code that looked old. Looks like they have deleted it so perhaps not relevant to the issue you have.

dwightwatson commented 3 months ago

I can see that the FcmMessage is correctly turned into a Kreait message under the hood - so it does seem that the notification information is being sent correctly to Firebase.

image

Without more information or a reproduction there's not much I can do here.